I've seen behavior exactly like you are talking about with old Excel formats 
and Excel files written by some 3rd party reporting tools.  Apparently the 
pre-2007 (non-OOXML) Excel file specification was never quite standardized.  My 
solution to date has been to discard those files and ask for Excel 2007+ 
formats for which I haven't seen strange errors like the below.  I'd be 
interested as well to know if anyone has an alternate solution.

-----Original Message-----
From: Eric B. [mailto:[email protected]] 
Sent: Thursday, July 07, 2011 12:27 PM
To: [email protected]
Subject: Anyway to ignore LeftoverDataException?

Hi,

I'm using POI 3.7 and trying to read an Excel file.  Upon instantiating 
an HSSFWorkbook I get the following error:

HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);

org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException: 
Initialisation of record 0xDA left 2 bytes remaining still to be read.
        at 
org.apache.poi.hssf.record.RecordInputStream.hasNextRecord(RecordInputStream.java:156)
        at 
org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:216)
        at 
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:442)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:263)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:188)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:305)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:286)
...


I have tried to open the excel file in Excel and OpenOffice, and both 
open the file without failure.  If I resave the file from either Excel 
or OO, then I am able to read it without difficulty.

Is this a POI error, or a file structure error?  If the later, is there 
any way to tell POI to ignore a LeftOverDataException?

Thanks,

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to