Every now and then, I get people contacting me about problems using my POIUtility.cfc. They are usually getting this error:
Object Instantiation Exception. An exception occurred when instantiating a java object.
While I think there might be several reasons that this object instantiation could occur, usually, with the POI Utility ColdFusion component, I find that it is due to the file path that's being used. The POI Utility requires a full file path. This means that you should be using something like ExpandPath( FILE ) when defining your file path. Running this code:
<cfset objSheet = objPOIUtility.ReadExcel( FilePath = "meals.xls" ) />
... will throw that object instantiation error since "meals.xls" is not a full path. However, running this code, with the full path, will not throw any error and will work just fine:
<cfset objSheet = objPOIUtility.ReadExcel( FilePath = ExpandPath( "meals.xls" ) ) />
Hope that helps with people having this problem.
Want to use code from this post? Check out the license.