Bug 57104 - LeftoverDataException: Initialisation of record 0x5B left 1 bytes remaining still to be read.
Summary: LeftoverDataException: Initialisation of record 0x5B left 1 bytes remaining s...
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.10-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on: 57093
Blocks:
  Show dependency tree
 
Reported: 2014-10-17 07:21 UTC by Simoli Desai
Modified: 2019-03-10 16:45 UTC (History)
0 users



Attachments
Problematic file (4.50 KB, application/vnd.ms-excel)
2014-10-17 12:07 UTC, Simoli Desai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simoli Desai 2014-10-17 07:21:27 UTC
I am trying to read from a Microsoft Excel 97-2003 Worksheet. There is no problem opening the file using Microsoft Excel or Open Office. poi can read the file once the file is opened and saved again in the same format. But i cannot implement this practice for each file I encounter. I cannot attach the problematic file because it has client information. Please help me with this.

The error I get is as follows:

org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException: Initialisation of record 0x5B left 1 bytes remaining still to be read.
        at org.apache.poi.hssf.record.RecordInputStream.hasNextRecord(RecordInputStream.java:156)
        at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:231)
        at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:480)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:301)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:264)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:199)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:342)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:323)
Comment 1 Nick Burch 2014-10-17 08:32:23 UTC
Any chance of the file that shows the problem, so we can look at why POI isn't knowing to read the whole record's data?
Comment 2 Simoli Desai 2014-10-17 12:07:08 UTC
Created attachment 32119 [details]
Problematic file

I found one more file with that gets me a similar error. I have attached it for you.

It throws the same LeftoverDataException.

The error goes like this:


Exception in thread "main" org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException: Initialisation of record 0x31 left 22 bytes remaining still to be read.
        at org.apache.poi.hssf.record.RecordInputStream.hasNextRecord(RecordInputStream.java:156)
        at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:231)
        at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:480)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:301)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:264)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:199)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:342)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:323)
Comment 3 Nick Burch 2014-10-17 13:42:49 UTC
We need one file per problematic record type + bytes remaining combination. While the exceptions look similar, the fix for each will be totally different

So, we need one for your "record type 0x5b + 1 byte remaining" case, and one for your "record type 0x31 + 22 bytes remaining" case
Comment 4 Simoli Desai 2014-10-20 07:49:09 UTC
I cannot provide you with the file for the other exception I get for record 0x5B left 1 bytes. Please use the file I have attached previously for the following error. It is fine if you look into this error and ignore the previous one because of lack of information.

Exception in thread "main" org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException: Initialisation of record 0x31 left 22 bytes remaining still to be read.
        at org.apache.poi.hssf.record.RecordInputStream.hasNextRecord(RecordInputStream.java:156)
        at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:231)
        at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:480)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:301)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:264)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:199)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:342)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:323)
Comment 5 Dominik Stadler 2014-11-10 21:14:06 UTC
I tried to debug this, but when looking this up in the spec POI parses the record correctly and it looks like this file is slightly off-standard and Excel somehow ignores the additional content. 

Dev-Info: There are multiple [FONT] records which additional 22 bytes each. POI seems to exactly follow the spec for FontRecord at "2.4.122 Font", but somehow all the FONT-entries in this XLS file have 22 additional bytes. The value of the first set of additional bytes is "13, 00, 01, 00, 00, 58, 01, 00, 00, 59, 5F, 29, 3F, 5F, 29, 3B, 5F, 28, 40, 5F, 29, 00".

Simoli, how exactly are these files produced? Via Excel or some other software that automatically produces them?
Comment 6 Simoli Desai 2014-11-14 06:18:12 UTC
Hi Dominik,

It must be a third party software that generates these files.

By the way, the 22 bytes for FontRecord... can these be skipped?

There is this other library i used instead of POI because I had to get on with my work, however I donot rely upon it completely. It parsed my file good. No data fields were missing, it threw me an error message. That is all.
Comment 7 Dominik Stadler 2015-06-20 15:40:02 UTC
BTW, this sounds quite similar to bug #57093