This bugzilla was created as a follow-on from: http://www.nabble.com/Error-opening-a-Excel-File-tp19083161p19162369.html 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.
Created attachment 22488 [details] from http://www.nabble.com/file/p19162369/CRE_CODIFICATION.xls
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.