Bug 46385

Summary: java.lang.IllegalStateException: Incorrect number of bytes written - expected 85 but got 47
Product: POI Reporter: Duc Nguyen <duc.nguyen>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: major CC: duc.nguyen
Priority: P1    
Version: 3.5-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Input spreadsheet for test-case

Description Duc Nguyen 2008-12-12 03:54:52 UTC
I just open a spreadsheet and save as with another name by POI (POI 3.5 beta 4, and Office Open XML Support (2008-12-01)):

HSSFWorkbook wb;
FileOutputStream fileOut;
wb = new HSSFWorkbook(
                new POIFSFileSystem(
                        new FileInputStream("input_file.xls")));
         
fileOut = new FileOutputStream("saveAs.xls");
wb.write(fileOut);
fileOut.close();


but I get error:

java.lang.IllegalStateException: Incorrect number of bytes written - expected 85 but got 47
	at org.apache.poi.hssf.record.StandardRecord.serialize(StandardRecord.java:39)
	at org.apache.poi.hssf.model.Workbook.serialize(Workbook.java:953)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1287)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1191)
	at poi_save_file.saveAs(poi_save_file.java:29)
	at poi_save_file.saveFile(poi_save_file.java:15)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
	at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
	at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
	at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
	at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
	at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
	at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
	at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
	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)
Comment 1 Duc Nguyen 2008-12-12 03:58:08 UTC
Created attachment 23010 [details]
Input spreadsheet for test-case
Comment 2 Josh Micich 2008-12-15 21:52:44 UTC

*** This bug has been marked as a duplicate of bug 46362 ***