Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This thread is old, but I notice that Apache now has a version of POI that's compatible with Excel's OOXML (.xlsx) file format. Support for this appears to have started with version 3.5 from what I can tell. I am running CF8 with Java version 1.6.0_4. Does anyone know if upgrading to the latest version of Java will give me access to the newer POI jar files that support Excel 2007?
I'm trying to use Ben Nadel's POIUtility.cfc to read Excel 2007 (xlsx) files, but I'm getting the dreaded "Object Instantiation Exception" exception because of this issue. Any advice would be greatly appreciated.
Thanks,
Kevin
Copy link to clipboard
Copied
Looks like I found the information I needed in Dirk's post on th
is thread of Ben Nadel's site: http://www.bennadel.com/blog/624-ColdFusion-POIUtility-cfc-Updates-And-Bug-Fixes.htm
Copy link to clipboard
Copied
>> Looks like I found the information I needed in Dirk's post
>> "... and of course you should remove the old poi class
Just be aware that CF uses the POI jars too. So it is possible you could break something by swapping out the jars.
Another option is to use the javaLoader to run both versions side by side.
http://javaloader.riaforge.org/
Copy link to clipboard
Copied
Thanks for the advice. I'll look into using javaloader.
Copy link to clipboard
Copied
Great advice cfSearching! Following these steps, I was able to successfully read an Office 2007 xlsx file into ColdFusion:
I used your instructions at http://cfsearching.blogspot.com/2009/02/how-to-install-poi-35-beta-on.html to install the latest Apache POI 3.7 files and then use JavaLoader to load them into the Server scope. Then I updated Ben Nadel's POI Utility as follows:
changes in POIUtility.cfc in function ReadExcel()
replace these lines:
LOCAL.ExcelFileSystem = CreateObject( "java", "org.apache.poi.poifs.filesystem.POIFSFileSystem" ).Init( LOCAL.FileInputStream );
LOCAL.WorkBook = CreateObject("java","org.apache.poi.hssf.usermodel.HSSFWorkbook").Init(LOCAL.ExcelFileSystem);
with this:
LOCAL.FileInputStream = CreateObject( "java", "java.io.FileInputStream" ).Init( ARGUMENTS.FilePath );
javaLoader = server[application.myJavaLoaderKey];
LOCAL.WorkBookFactory = javaLoader.create("org.apache.poi.ss.usermodel.WorkbookFactory");
LOCAL.WorkBook = LOCAL.WorkBookFactory.create(LOCAL.FileInputStream);
Thanks again for the help!!!
Copy link to clipboard
Copied
LOCAL.WorkBookFactory =
Great! Good use of the WorkBookFactory .. and thanks for posting the code.
-Cheers
Leigh