I'm creating a scheduled task which downloads an excel file from a third-party site and then updates the database accordingly.
I can successfully download the file via a url (ie http://www.example.com/myExcel.xls
). But when I try to read it afterwards, using Ben Nadel's POIUtility.cfc, I get all kinds of errors. It seems due to the fact that when I download the file with CFHTTP
it is saved in read-only format.
Does this behavior sound familiar to anybody or does anybody know how to save the file so it is not read-only?
Thanks in advance.
Part of the code:
<cfhttp method="get"
url="http://www.example.com/myExcel.xls"
path="#expandpath('xls')#" file="stocks.xls" />
<cfset objPOI = CreateObject("component", "POIUtility").Init()/>
<cfset arrSheets = objPOI.ReadExcel( FilePath = ExpandPath("xls/stocks.xls")
, HasHeaderRow = true) />
UPDATE 22nd of june: The error I receive is the following:
Object instantiation exception.
An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. Error: ''.
The error occurred in /Volumes/RAID/DATA/ColdFusion9/wwwroot/website/POIUtility.cfc: line 883
Called from /Volumes/RAID/DATA/ColdFusion9/wwwroot/website/autoUpdateStock.cfm: line 36
Called from /Volumes/RAID/DATA/ColdFusion9/wwwroot/website/POIUtility.cfc: line 883
Called from /Volumes/RAID/DATA/ColdFusion9/wwwroot/website/autoUpdateStock.cfm: line 36
881 : "org.apache.poi.hssf.usermodel.HSSFWorkbook"
882 : ).Init(
883 : LOCAL.ExcelFileSystem
884 : );
885 :
If I open the downloaded file directly from within my OS the status bar in excel also says "(read-only)". If I save the file the a different filename and then use that new filename in the POI code it works without a problem.
I had a similar error a while ago where the problem was unsupported excel-stuff in the excel file which caused the POI the give the same error. But this excel file does not contain special things like graphs etc, just plain data without datafilters.
I'm thinking maybe the source file is saved in an unsupported excel format for the POI utility but when I view the info-window of the file it says "Kind: Microsoft Excel 97-2004 workbook" which is the same as with other files I tried with (that work).