Bug 45698

Summary: LinkTable fails to read properly with multiple EXTERNSHEET records
Product: POI Reporter: Josh Micich <josh>
Component: HSSFAssignee: POI Developers List <dev>
Severity: critical    
Priority: P4    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: from http://www.nabble.com/file/p19162369/CRE_CODIFICATION.xls

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.