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
Created attachment 21394 [details] well format excel
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
The bug is not reproducible in poi-3.1-beta1. Yegor
(In reply to comment #3) > The bug is not reproducible in poi-3.1-beta1. > Yegor Thank you a lots