DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43408>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43408

           Summary: org.apache.poi.hssf.record.RecordFormatException at BOF
                    record
           Product: POI
           Version: 3.0
          Platform: Other
        OS/Version: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: [EMAIL PROTECTED]


My Java code
  ...
  fs = new POIFSFileSystem( new FileInputStream( sPath ) );
  m_workbook = new HSSFWorkbook(fs);

throws exception while creating new HSSFWorkbook instance:

org.apache.poi.hssf.record.RecordFormatException: Unable to construct record
instance
        at 
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:191)
        at 
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:115)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:205)
        at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:153)
        at ...
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown 
Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at 
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:179)
        ... 12 more
Caused by: java.lang.ArrayIndexOutOfBoundsException
        at
org.apache.poi.hssf.record.RecordInputStream.checkRecordPosition(RecordInputStream.java:132)
        at 
org.apache.poi.hssf.record.RecordInputStream.readInt(RecordInputStream.java:155)
        at org.apache.poi.hssf.record.BOFRecord.fillFields(BOFRecord.java:118)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:56)
        at org.apache.poi.hssf.record.BOFRecord.<init>(BOFRecord.java:99)
        ... 17 more

Exception is raised within org.apache.poi.hssf.record.BOFRecord.fillFields() at
these statements:
...
field_5_history  = in.readInt();
field_6_rversion = in.readInt();

I cannot attach example of excelsheet producing this error since it contains my
customer's private data. However, it seems the XLS format is quite old because
BOFRecord member "field_4_year" is "1995".

I guess that this XLS file doesn't have fields "history" and "rversion" in the
BOFRecord.

Changing the Java code to
try {
  field_5_history  = in.readInt();
  field_6_rversion = in.readInt();
}
catch (ArrayIndexOutOfBoundsException aioobe ) {} 

helped me to get rid of the problem and my XLS file was opened well afterwards.
Please, investigate possibility to add this fix to official POI package.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to