Bug 52300 - Corrupted File after cloneSheet()
Summary: Corrupted File after cloneSheet()
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.8-dev
Hardware: PC Windows XP
: P2 normal with 8 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 52312 (view as bug list)
Depends on:
Blocks: 53010
  Show dependency tree
 
Reported: 2011-12-07 12:33 UTC by Stefan Helfert
Modified: 2012-08-12 11:41 UTC (History)
2 users (show)



Attachments
Template File (59.50 KB, application/vnd.ms-excel)
2011-12-07 12:33 UTC, Stefan Helfert
Details
Created corrupted File (63.50 KB, application/vnd.ms-excel)
2011-12-07 12:34 UTC, Stefan Helfert
Details
Testprogram (993 bytes, text/java)
2011-12-07 12:34 UTC, Stefan Helfert
Details
Xls-file with 20 images and 3 shapes (125.00 KB, application/vnd.ms-excel)
2011-12-12 13:25 UTC, Ant0xA
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Helfert 2011-12-07 12:33:54 UTC
Created attachment 28048 [details]
Template File

Hi, 

Iam using templateFiles (*.xlt) and want to copy some sheets to reuse them.
The template files contains a image.

But during the copy progress I got the following error:
WARNING: 8 bytes remaining but no space left

When I want to open the new file afterwards I got a Errormessage and Excel repairs it.

After that the file is open and still looks good (Image is on both sheets).

I attached the template file and a litte Testprogram.

public class POITemplateCopyTest {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
	InputStream is = new FileInputStream(new File("D:\\BugReport\\SourceTemplate.xlt"));
	POIFSFileSystem poifs = new POIFSFileSystem(is);
	HSSFWorkbook wb = new HSSFWorkbook(poifs);
	is.close();
	
	wb.cloneSheet(1);
	
	wb.write(new FileOutputStream(new File("D:\\BugReport\\TemplateTestCopy.xls")));
	System.out.println("Done");
	
	}

}
Comment 1 Stefan Helfert 2011-12-07 12:34:16 UTC
Created attachment 28049 [details]
Created corrupted File
Comment 2 Stefan Helfert 2011-12-07 12:34:30 UTC
Created attachment 28050 [details]
Testprogram
Comment 3 Ant0xA 2011-12-12 12:51:09 UTC
*** Bug 52312 has been marked as a duplicate of this bug. ***
Comment 4 Ant0xA 2011-12-12 13:12:49 UTC
Hi. I had even bug. More often it becomes apparent for cloning sheets with shapes. 
And when I clone sheet with 20 images and 3 shapes, I have exception:
WARNING: 32 bytes remaining but no space left
WARNING: 136 bytes remaining but no space left
WARNING: 32 bytes remaining but no space left
WARNING: 136 bytes remaining but no space left
WARNING: 32 bytes remaining but no space left
WARNING: 136 bytes remaining but no space left
WARNING: 32 bytes remaining but no space left
WARNING: 136 bytes remaining but no space left
Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: 9192 bytes written but getRecordSize() reports 9296
	at org.apache.poi.hssf.record.EscherAggregate.serialize(EscherAggregate.java:488)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook$SheetRecordCollector.serialize(HSSFWorkbook.java:1263)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1309)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1209)
	at TestWorkbookCreating.main(TestWorkbookCreating.java:44)

I added this file to attachments.
Comment 5 Ant0xA 2011-12-12 13:25:16 UTC
Created attachment 28067 [details]
Xls-file with 20 images and 3 shapes

During cloning the shape with name "cb_en" of this file occurs an exception.
Comment 6 Evgeniy Berlog 2012-08-12 11:41:19 UTC
This problem should be fixed in trunk.

Please try with a nightly build - see download links on http://poi.apache.org/
or build yourself from SVN trunk, see http://poi.apache.org/subversion.html