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)
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?
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)
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
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)
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?
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.
BTW, this sounds quite similar to bug #57093