Bug 57669 - RuntimeException: Unexpected record type (org.apache.poi.hssf.record.FeatHdrRecord)
Summary: RuntimeException: Unexpected record type (org.apache.poi.hssf.record.FeatHdrR...
Status: RESOLVED DUPLICATE of bug 52447
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.10-FINAL
Hardware: PC All
: P2 major with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on: 50426 52447 53984
Blocks:
  Show dependency tree
 
Reported: 2015-03-06 08:24 UTC by Diptesh
Modified: 2022-01-01 21:23 UTC (History)
0 users



Attachments
Problem file (196.74 KB, text/plain)
2015-03-06 10:03 UTC, Diptesh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Diptesh 2015-03-06 08:24:30 UTC
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.
Comment 1 Nick Burch 2015-03-06 08:39:07 UTC
Does the problem still occur with POI 3.12 beta 1?
Comment 2 Diptesh 2015-03-06 08:55:51 UTC
Has the bug been fixed in POI 3.12 beta 1? Do you want us to test the same in 3.12 beta 1?
Comment 3 Diptesh 2015-03-06 09:53:02 UTC
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]
Comment 4 Diptesh 2015-03-06 10:03:59 UTC
Created attachment 32547 [details]
Problem file

Please look into the line number 7491 and 7492
Comment 5 Diptesh 2015-03-09 04:29:32 UTC
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:
Comment 6 Nick Burch 2015-03-13 19:04:51 UTC
Any chance you could upload a file that shows the problem? We can then use that in a unit test for the fix
Comment 7 Diptesh 2015-03-16 07:35:34 UTC
Unfortunately the excel file we received contains confidential information which is the reason why we cannot upload the problem file.
Comment 8 Nick Burch 2015-03-16 10:43:24 UTC
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?
Comment 9 Dominik Stadler 2015-05-01 20:49:11 UTC
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.
Comment 10 Deepesh Ramrakhyani 2016-05-30 06:34:59 UTC
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.
Comment 11 Dominik Stadler 2022-01-01 21:23:28 UTC
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 ***