You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Luce, Marc" <Ma...@bankofamerica.com> on 2006/03/13 22:45:07 UTC

Help opening a file

I need to open an Excel file that is created by one of our clients.  I have no idea what tool (if any) creates the Excel.  Whenever I try to open the file using the following code:

	        try
	        {
	            FileInputStream fis = new FileInputStream(file);
	            workbook = new HSSFWorkbook (fis );
	        } catch (IOException e)
	        {
	            logger.debug("Unable to open file '" + file.getName() + "'");
	        }

I get a ClassCastException and here is the stack trace.

	java.lang.ClassCastException: org.apache.poi.hssf.record.LabelRecord
		at java.util.TreeMap.compare(TreeMap.java:1085)
		at java.util.TreeMap.getEntry(TreeMap.java:345)
		at java.util.TreeMap.get(TreeMap.java:264)
		at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.insertCell(ValueRecordsAggregate.java:92)
		at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.construct(ValueRecordsAggregate.java:151)
		at org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:206)
		at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:149)
		at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:175)
		at shared.util.JPMFileScraper.scrapeFile(JPMFileScraper.java:95)
		at shared.util.JPMFileScraper.scrapeFiles(JPMFileScraper.java:176)
		at shared.util.JPMFileScraper.main(JPMFileScraper.java:315)
	Exception in thread "main" 


This is the file that I cannot open. 

  <<CHEC 2004-2 - 2006-01.XLS>> 


Any help would be appreciated.



Re: Help opening a file

Posted by Eli Spizzichino <ml...@javanet.info>.
Luce, Marc wrote:
> I need to open an Excel file that is created by one of our clients.  
[snip]
Hi Luce,
Opening that file I got
      [java] java.lang.reflect.InvocationTargetException
      [java] 	at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)......
      [java] Caused by: java.lang.ArrayIndexOutOfBoundsException
      [java] 	at java.lang.System.arraycopy(Native Method)
      [java] 	at 
org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
....

I then opened it with OpenOffice re saved as excel 97 then I got no 
problem at all to read/write it with POI.
You can test by yourself with the testing program I attached to my last 
email.
Probably they saved as excel 95?
regards
Eli

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/