Bug 51440

Summary: Unable to construct record instance
Product: POI Reporter: Yanjiang Yu <yuyj>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: critical    
Priority: P2    
Version: 3.7-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: the excel file
the end of the excel file.

Description Yanjiang Yu 2011-06-28 04:15:30 UTC
Created attachment 27217 [details]
the excel file

Error occur when i deal excel 2003 files with poi.
(btw: the hssf.xls file is created by ms office 2003 directly.

and i use FileFormatConverters.exe Compatibility Pack for opening office2007 files.
http://www.microsoft.com/download/en/details.aspx?id=3

now i see FileFormatConverters.exe is the right reason why this error occur.
please see the picture attached.

The code like this: (hssf.xls as attached.)
=============================================================
import java.io.FileInputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class PoiTest {
	public static void main(String[] args) {
		FileInputStream in;
		try {

			in = new FileInputStream("e:/hssf.xls");

			POIFSFileSystem f = new POIFSFileSystem(in);
			HSSFWorkbook wb = new HSSFWorkbook(f);

			System.out.println("ok");

		} catch (Exception e) {

			e.printStackTrace();
		}

	}

}

The exception as bellow:
=================================================================
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance
	at org.apache.poi.hssf.record.RecordFactory$ReflectionConstructorRecordCreator.create(RecordFactory.java:65)
	at org.apache.poi.hssf.record.RecordFactory.createSingleRecord(RecordFactory.java:300)
	at org.apache.poi.hssf.record.RecordFactoryInputStream.readNextRecord(RecordFactoryInputStream.java:270)
	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:263)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:188)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:170)
	at PoiTest.main(PoiTest.java:37)
Caused by: org.apache.poi.hssf.record.RecordFormatException: Expected to find a ContinueRecord in order to read remaining 4 of 14 chars
	at org.apache.poi.hssf.record.RecordInputStream.readStringCommon(RecordInputStream.java:353)
	at org.apache.poi.hssf.record.RecordInputStream.readString(RecordInputStream.java:293)
	at org.apache.poi.hssf.record.SupBookRecord.<init>(SupBookRecord.java:96)
	at sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.apache.poi.hssf.record.RecordFactory$ReflectionConstructorRecordCreator.create(RecordFactory.java:57)
	... 8 more
Comment 1 Yanjiang Yu 2011-06-28 05:43:30 UTC
Created attachment 27218 [details]
the end of the excel file.

the end of the two excel files.
Comment 2 Nick Burch 2011-06-28 10:22:48 UTC
Does the error still happen with POI 3.8 beta 3?
Comment 3 Yanjiang Yu 2011-06-29 03:07:50 UTC
(In reply to comment #2)
> Does the error still happen with POI 3.8 beta 3?

YES
Comment 4 Yegor Kozlov 2011-07-02 09:47:05 UTC
the problem is not reproducible with the latest build from trunk. 

Yegor

(In reply to comment #3)
> (In reply to comment #2)
> > Does the error still happen with POI 3.8 beta 3?
> 
> YES