We received an excel file from an external source and trying to read the file through POI, we are getting the exception below: java.lang.RuntimeException: Unexpected record type (org.apache.poi.hssf.record.FeatHdrRecord) at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.<init>(RowRecordsAggregate.java:97) ~[poi-3.10.1.jar:3.10.1] at org.apache.poi.hssf.model.InternalSheet.<init>(InternalSheet.java:166) ~[poi-3.10.1.jar:3.10.1] at org.apache.poi.hssf.model.InternalSheet.createSheet(InternalSheet.java:121) ~[poi-3.10.1.jar:3.10.1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:311) ~[poi-3.10.1.jar:3.10.1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:264) ~[poi-3.10.1.jar:3.10.1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:199) ~[poi-3.10.1.jar:3.10.1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:181) ~[poi-3.10.1.jar:3.10.1] If the file is opened and saved thereafter, the exception no longer occurs and the file is processed successfully.
Does the problem still occur with POI 3.12 beta 1?
Has the bug been fixed in POI 3.12 beta 1? Do you want us to test the same in 3.12 beta 1?
I have tried with the POI 3.12 beta 1 but getting the same error. Below is the error stack trace: java.lang.RuntimeException: Unexpected record type (org.apache.poi.hssf.record.FeatHdrRecord) at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.<init>(RowRecordsAggregate.java:97) ~[poi-3.12-beta1-20150228.jar:3.12-beta1] at org.apache.poi.hssf.model.InternalSheet.<init>(InternalSheet.java:217) ~[poi-3.12-beta1-20150228.jar:3.12-beta1] at org.apache.poi.hssf.model.InternalSheet.createSheet(InternalSheet.java:156) ~[poi-3.12-beta1-20150228.jar:3.12-beta1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:336) ~[poi-3.12-beta1-20150228.jar:3.12-beta1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:288) ~[poi-3.12-beta1-20150228.jar:3.12-beta1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:223) ~[poi-3.12-beta1-20150228.jar:3.12-beta1] at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:206) ~[poi-3.12-beta1-20150228.jar:3.12-beta1]
Created attachment 32547 [details] Problem file Please look into the line number 7491 and 7492
The following problem can be fixed in two ways: 1) Modifying the contstructor in RowRecordsAggregate.java: //include case FeatHdrRecord.sid: continue; 2) Modifying the isEndOfRowBlock() API of RecordOrderer.java: //include case FeatHdrRecord.sid:
Any chance you could upload a file that shows the problem? We can then use that in a unit test for the fix
Unfortunately the excel file we received contains confidential information which is the reason why we cannot upload the problem file.
I'm very reluctant to try to fix this without a test file. With no test file, it's hard for us to ensure that the fix has worked properly, the correct data is coming back, and there are no side-effects on that file. With no test file, it's impossible for us to ensure that the fix remains into the future as the codebase evolves, and no warning that we might have broken anything If you, or someone else, could find a file that shows the problem, then we can use that. Otherwise, perhaps you could talk to whoever generated/gave you the file, and ask them to make another one without the information in? Or perhaps take a hex editor to your file you have, and replace the sensitive text in it?
There are a number of similar bugs, all of them happen with files that are not produced by Excel itself and thus are likely slightly broken. Unfortunately a simple stable fix is not always possible, especially here when we do not even have a sample file to work against.
Hi All, I am also currently facing the same issue. The code changes that we are planning to do based on the suggestion provided by Diptesh are, case HyperlinkRecord.sid: continue; The file that we are trying to load which is given the above mentioned is available at . https://www.jse.co.za/_layouts/15/DownloadHandler.ashx?FileName=/Safex/mtmdata/All%20Contract%20Details.xls Please let us know will this fix work and what will be the impact of this change. Thanks in Advance. Regards, Deepesh Ramrakhyani.
The changes for Bug #52447 should fix the cases with "HyperlinkRecord", for others we did not receive a test-file and thus cannot work on a fix. Please provide a sample-file which triggers this problem in a new bug report so we can review if there is a way to support more such slightly broken files. *** This bug has been marked as a duplicate of bug 52447 ***