Reputation: 46
I am using Ben Nadel's POIUtility.cfm to read and write to Excel files. There are some files which I can read very easily using the given code/file. But for some other files, I keep getting an instantiation error. I cannot figure out what's going wrong.
Code:
<cfset arrSheets = objPOI.ReadExcel(
FilePath = ExpandPath( "./File giving error.xls" ),
HasHeaderRow = true
) />
Error:
Object instantiation exception.
An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class.
I'm using CF10, site hosted locally on IIS. Link to sample file.
Upvotes: 0
Views: 638
Reputation: 28873
Short answer:
The format of the file you are trying to read is too old (Excel 95). POI only supports Excel 97 and later. Unless you really have files in that old format, I would not worry about it.
Given that spreadsheet functions are built into CF 10, you probably do not even need the POIUtility.
Longer answer:
If you look at the end of the stack trace, the "caused by" message explains that the format Excel 95 (BIFF5), is not supported. (It is over twenty years old!). For that file to be compatible with POI, you would need to it with another tool, like Excel, and save it in Excel 97 format (or later).
Caused by: org.apache.poi.hssf.OldExcelFormatException: The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)
As an aside, the POIUtility was originally designed back in the days of ColdFusion 7, because it had no official support for manipulating spreadsheets. However, CF7 did include the POI library. So that component was written to fill the gap. Then along came CF9, which had spreadsheet functions already baked in, so the component became less necessary.
Upvotes: 0