Update: This project has been released to RIA Forge as CFXL. Check it out at http://cfxl.riaforge.org/
A long time ago, for a previous company... back in the CFMX 6 days, I wrote code for leveraging JExcel API in ColdFusion. We wanted to have our excel reports professional. The reporting feature that is in ColdFusion today wasn't around, and even now that it is, I still really like this method.
For a session at MAX 2006 - Developing ColdFusion-Java Hybrid Applications, I rewrote this functionality as a quick demo of what could be done pretty easily. Looking back at even that code, I saw a lot of areas that needed improvement. So, I've rewritten the code again and am releaseing it as open source. Version .1 can do the following. Take an existing excel spreadsheet with images/logos, charts defined, etc., and modify the values of numerics, strings, dates, and booleans. The code makes modifications in a ByteArrayOutputStream and streams them to the browser... read that as... it doesn't write to a file unless you tell it to, so it's wicked FAST!
Anything that works more than that is just gravy at this point. :)
What you'll find in the zip file...
- A component that abstracts and simplifies JExcelAPI
- A pair of custom tags for simplifying things even further
- Example files on how to use either of these methods
If you think this is useful code, let me know! I may add it to RIAForge and beef it up if people actually use it. Otherwise, I will leave it as an interesting example of how to leverage and simplify an open source Java API with ColdFusion.
Update: Here is the code example in case you're too busy to download and configure all of this to see what it does. :)
jxl = createObject("component","com.cfinsider.jxl").init("#GetDirectoryFromPath(GetCurrentTemplatePath())#/demo.xls");
jxl.setCell("A",13,"My Example Excel File");
or if you prefer tags
<cf_jxlparam column="A" row="13" value="My Example Excel File"/>
<cf_jxlparam column="A" row="14" value="100"/>
<cf_jxlparam column="A" row="15" value="100"/>
<cf_jxlparam column="A" row="16" value="200"/>
<cf_jxlparam column="A" row="17" value="500"/>
<cf_jxlparam column="A" row="18" value="1000"/>
The output is something like this... but probably nicer because you will make it look good. :)
Happy coding, :) Jason