Bug 50967 - org.apache.poi.hssf.record.RecordFormatException: Unhandled Continue Record
org.apache.poi.hssf.record.RecordFormatException: Unhandled Continue Record
Status: RESOLVED FIXED
Product: POI
Classification: Unclassified
Component: HSSF
3.7-FINAL
PC Windows XP
: P2 critical (vote)
: ---
Assigned To: POI Developers List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-03-24 11:52 UTC by Pepe
Modified: 2011-04-01 09:46 UTC (History)
1 user (show)



Attachments
error by creating HSSFWorkbook (437.92 KB, application/zip)
2011-03-24 12:00 UTC, Pepe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pepe 2011-03-24 11:52:11 UTC
When trying to create the object HSSFWorkbook i got the following exception:

org.apache.poi.hssf.record.RecordFormatException: Unhandled Continue Record at org.apache.poi.hssf.record.RecordFactoryInputStream.readNextRecord(RecordFactoryInputStream.java:342)
        at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:236)
        at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:392)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:276)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:201)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:317)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:298)

Attached the file used.

Thanks in advance for your help!!
Comment 1 Nick Burch 2011-03-24 11:54:07 UTC
Could you please try with 3.8 beta 1 and see if that fixes it? There have been some fixes in this area since 3.7.
Comment 2 Pepe 2011-03-24 12:00:24 UTC
Created attachment 26796 [details]
error by creating HSSFWorkbook

the XLS file ist in the zip file
Comment 3 Pepe 2011-03-24 12:06:39 UTC
(In reply to comment #1)
> Could you please try with 3.8 beta 1 and see if that fixes it? There have been
> some fixes in this area since 3.7.

Ok, i tried with 3.8 as well, here the exception:

org.apache.poi.hssf.record.RecordFormatException: Unhandled Continue Record followining class org.apache.poi.hssf.record.ExtSSTRecord at org.apache.poi.hssf.record.RecordFactoryInputStream.readNextRecord(RecordFactoryInputStream.java:342)
        at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:236)
        at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:442)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:298)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:260)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:204)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:340)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:321)


Thanks for your help!
Comment 4 Yegor Kozlov 2011-03-25 08:59:31 UTC
What software created this file? Excel 2010 complains that the file is unreadable and when I click Yes to recover then nothing happens. 

OpenOffice can read this file OK. 

Yegor
Comment 5 Pepe 2011-03-25 11:14:55 UTC
Hello, 
thanks for your response. It is hard to tell the software that created the file. We receive a lot of files from different customers and each of them has his own software.
This is not the only file which throws the exception, so a one-time-error can be discarded.

BR


(In reply to comment #4)
> What software created this file? Excel 2010 complains that the file is
> unreadable and when I click Yes to recover then nothing happens. 
> 
> OpenOffice can read this file OK. 
> 
> Yegor
Comment 6 Yegor Kozlov 2011-03-27 06:34:57 UTC
Fixed in r1085900, junit added. 

Strictly speaking, the problematic ExtSST record is not correct.

This record stores a set of buckets that are used to perform a quick lookup of a string within the shared string table.

According to the Excel spec (section 2.4.107 ExtSST), the number of buckets depends on the number of unique strings in the workbook and defined by the following formula:

numBuckets = num_unique_strings mod max(((num_unique_strings / 128) + 1),8)

In your file num_unique_strings=12378 and the number of buckets should be 


numBuckets = 12378 % Math.max(12378 / 128 + 1, 8) = 59

The bucket size is eight bytes and the expected record length is 8 + 2 + 59*8 = 482 bytes.

In your file numBuckets=1548 and the record size including the continue remainder is 12394 bytes! 

Excel 2003 and OpenOffice can read the attached file without any warnings, but on re-save the ExtSST record is truncated to match the formulas above. I fixed POI to behave similarly. Excel2010 can't read such file which seems a regression. 

Yegor
Comment 7 Pepe 2011-03-28 03:27:01 UTC
Hello Yegor,

many thanks for your effort!! I really appreciate it. 
Just one more question, do I have to wait until 3.8-beta2 or is there another way to start using it?

BR.
Comment 8 Pepe 2011-03-28 03:27:54 UTC
Hello Yegor,

many thanks for your effort!! I really appreciate it. 
Just one more question, do I have to wait until 3.8-beta2 or is there another way to start using it?

BR.
Comment 9 French.Koala 2011-04-01 08:28:01 UTC
I got the same exception by using LibreOffice 3.3 (LibreOffice 3.3.2 
OOO330m19 (Build:202)
tag libreoffice-3.3.2.2
Comment 10 Yegor Kozlov 2011-04-01 09:43:25 UTC
(In reply to comment #9)
> I got the same exception by using LibreOffice 3.3 (LibreOffice 3.3.2 
> OOO330m19 (Build:202)
> tag libreoffice-3.3.2.2

Which version of POI? The problem was fixed in r1085900 on 2011-03-27. Please try the latest build from trunk. 

If the problem is still there, please upload the problematic file, without it we can't do much.

Yegor
Comment 11 Yegor Kozlov 2011-04-01 09:46:19 UTC
(In reply to comment #8)
> Hello Yegor,
> 
> many thanks for your effort!! I really appreciate it. 
> Just one more question, do I have to wait until 3.8-beta2 or is there another
> way to start using it?
> 

If all is OK, 3.8-beta2 will be on the mirrors after April 8. The release vote on the poi-dev list is in progress and you are welcome to vote.

If you want to try ASAP then build POI jars yourself or download daily builds from http://encore.torchbox.com/poi-cvs-build/

Yegor