cfExcelProxy Launched
Aug 3
Ray Camden just approved my project over at RIAForge, so I thought it was a great oppurtunity to talk about it here. Basically, cfExcelProxy is my attempt at using Apache's POI HSSF java libraries to talk to and modify Microsoft Excel files.
Here are the available methods from the main object, cfExcelProxy.cfc:
public - newWorkbook - ( ) cfExcelProxy
Creates a new blank workbook.
public - read - ( string filename ) cfExcelProxy
Reads in an existing workbook (from file).
public - createSheet - ( string name ) cfExcelProxy
Create a new sheet in the workbook.
public - setCell - ( string sheet , numeric row , numeric cell , string value , string class ) cfExcelProxy
Set the value of a cell.
public - dumpQuery - ( string sheet , query query , numeric row , numeric cell , string headerClass , string bodyClass , string collist ) cfExcelProxy
Dump the contents of a query into a sheet, with a starting row and cell.
public - createClass - ( string className , struct props ) cfExcelProxy
Create a class for future use (with setCell).
public - getCellValue - ( string sheet , numeric row , numeric cell ) string
Returns the contents of a cell.
public - getCellRangeValueAsArray - ( string sheet , numeric startrow , numeric startcell , numeric endrow , numeric endcell ) array
Retrieve the contents of a range of cells, and return it as an array.
public - getQueryFromCells - ( string sheet , numeric row , numeric cell , boolean header ) query
Attemps to rebuild a dumped query, from a starting position.
public - autoAdjust - ( string sheet , numeric row ) cfExcelProxy
Allows to auto-adjust the width of the columns.
public - write - ( ) Binary
Returns the binary output from this workbook.
Here's the project's link up at RIAForge. Feel free to download the files and play around with them, let me know what you think and if you have any ideas / questions / suggestions / complaints / insults please let me know ;).
Edit: I changed new for newWorkbook. As Radek pointed out in the comments, new may become a reserved word in CF9. Better safe than sorry! I committed the change to the repository, and I'm just about to release the updated package up at RIAForge.
#1 by Brian Rinaldi on 8/3/08 - 5:27 PM
#2 by Francois Levesque on 8/3/08 - 5:51 PM
#3 by radekg on 8/4/08 - 3:53 AM
#4 by Francois Levesque on 8/4/08 - 6:58 AM
Thanks for the info, I hadn't thought of that. I changed the method name to prevent conflicts.
#5 by Jose on 8/4/08 - 9:55 AM
Thanks
#6 by Francois Levesque on 8/4/08 - 10:51 AM
I did a quick search on Google and couldn't find anything, however Apache's POI library also includes objects for interacting with MS-Word: http://poi.apache.org/hwpf/index.html. Using the same logic than with HSSF it should be easy enough to create simple Word files with Coldfusion.
#7 by Jose on 8/4/08 - 11:08 AM
Yea, I also saw that but it looks to be pretty outdated and not supported. Hopefully CF9's cfdocument tag will add support for MSWord and/or RTF.
#8 by Vaixe on 9/1/10 - 1:15 PM
Howeever, cfExcelProxy wasn't able to open a .xlsx file. Is it out-of-the-box ready to handle MS Excel 2007 files or does it need tweaking? Is there a revised version somewhere taking care of that situation?
Thanks!
#9 by Francois Levesque on 9/1/10 - 1:27 PM
cfExcelProxy does not support .xlsx files. MS decided to completely change the way their files were stored and therefore the underlying Java classes used by this object to open/write Excel files cannot interpret them. Sorry!