Bug 44235 - Ms Excel can't open save as excel file
Summary: Ms Excel can't open save as excel file
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-14 19:14 UTC by longsebo
Modified: 2008-05-05 17:56 UTC (History)
0 users



Attachments
well format excel (87.00 KB, application/octet-stream)
2008-01-14 19:15 UTC, longsebo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description longsebo 2008-01-14 19:14:23 UTC
FileInputStream fIn;
    	HSSFWorkbook workbook ;
    	HSSFSheet sheet;
    	HSSFCell cell;
    	try {
			fIn = new FileInputStream("c://PM0037.xls");
			workbook = new HSSFWorkbook(fIn);
			sheet = workbook.getSheetAt(0);
			cell = sheet.getRow(6).getCell((short)3);
			//cell.setCellValue(1019.2);

	        FileOutputStream fOut = new FileOutputStream("c:/test.xls");
	
	        workbook.write(fOut);
	        fOut.flush();
	        fOut.close();
			 
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//when use excel 2003 open test.xls is fails,report open fails!need repair.
//when use poi open c:\test.xls report exception:
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record 
instance
	at org.apache.poi.hssf.record.RecordFactory.createRecord
(RecordFactory.java:191)
	at org.apache.poi.hssf.record.RecordFactory.createRecords
(RecordFactory.java:115)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:205)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:257)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:238)
	at plantix.report.poi.TestPOI.testOpenWorkBookComplexStyle
(TestPOI.java:108)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run
(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run
(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
(RemoteTestRunner.java:196)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
	at org.apache.poi.hssf.record.RecordFactory.createRecord
(RecordFactory.java:179)
	... 21 more
Caused by: org.apache.poi.hssf.record.RecordFormatException: Expected continue 
record.
	at org.apache.poi.hssf.record.UnicodeString.fillFields
(UnicodeString.java:243)
	at org.apache.poi.hssf.record.UnicodeString.<init>
(UnicodeString.java:117)
	at org.apache.poi.hssf.record.SSTDeserializer.manufactureStrings
(SSTDeserializer.java:49)
	at org.apache.poi.hssf.record.SSTRecord.fillFields(SSTRecord.java:368)
	at org.apache.poi.hssf.record.Record.<init>(Record.java:56)
	at org.apache.poi.hssf.record.SSTRecord.<init>(SSTRecord.java:104)
	... 26 more
Comment 1 longsebo 2008-01-14 19:15:30 UTC
Created attachment 21394 [details]
well format excel
Comment 2 Yegor Kozlov 2008-01-15 00:34:21 UTC
Thanks for the bug report. 
Looks like something is wrong with the serialization of unicode strings. 
If I change all fonts to Arial the test passes but it fails with the original
(Chinese) fonts. 
The code responsible for serialization of strings is quite complicated
(SSTRecord and related classes). SO, it will take some time to fix. 

Yegor
Comment 3 Yegor Kozlov 2008-05-05 09:14:13 UTC
The bug is not reproducible in poi-3.1-beta1.

Yegor
Comment 4 longsebo 2008-05-05 17:56:15 UTC
(In reply to comment #3)
> The bug is not reproducible in poi-3.1-beta1.
> Yegor

Thank you a lots