Bug 45698 - LinkTable fails to read properly with multiple EXTERNSHEET records
Summary: LinkTable fails to read properly with multiple EXTERNSHEET records
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC Windows XP
: P4 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-08-27 19:17 UTC by Josh Micich
Modified: 2008-08-27 20:11 UTC (History)
0 users

from http://www.nabble.com/file/p19162369/CRE_CODIFICATION.xls (778.15 KB, application/x-tar)
2008-08-27 19:25 UTC, Josh Micich

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Micich 2008-08-27 19:17:30 UTC
This bugzilla was created as a follow-on from:

The attached xls file has several EXTERNSHEET records present where single one should have been written.  POI throws an exception when attempting to read the file:

Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: Error reading bytes
    at org.apache.poi.hssf.record.RecordInputStream.nextRecord(RecordInputStream.java:115)
    at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:123)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:246)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:169)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:151)
Excel (2007) opens the file without obvious error.
When the file is re-saved by Excel, POI read it without throwing an exception.
Comment 2 Josh Micich 2008-08-27 20:11:45 UTC
Fixed in svn r689704.

It looks like whatever application has written this sample file has written out multiple ExternSheetRecords instead of multiple RefSubRecords within a single ExternSheetRecord.  When this unusual condition is detected, POI will now combine the records into one (which is hopefully the right thing to do). 

Junit added to make sure the observed RecordFormatException has been averted.

However, there are more problems concerning this file.  Bug 45699 has been opened to manage those.