Bug 17475 - Removal of sheets with diagrams corrupts file
Summary: Removal of sheets with diagrams corrupts file
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC All
: P3 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-27 11:32 UTC by Henning Boeger
Modified: 2009-04-17 11:32 UTC (History)
0 users



Attachments
Excel file for reproducing the bug (15.00 KB, application/octet-stream)
2003-03-03 14:30 UTC, Henning Boeger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Henning Boeger 2003-02-27 11:32:26 UTC
If I use Methode removeSheetAt on a sheet which contains a diagram, Excel 2000 
SR-1 crashed when opening the modified file.

The original Excel file is a simple book created from scratch. It contains two 
sheets, each containing one simple line diagram.

The code to read, modify and write the file is as follows:

HSSFWorkbook book = new HSSFWorkbook(new FileInputStream(path));
book.removeSheetAt(0);
FileOutputStream fOut = new FileOutputStream(path);
book.write(fOut);
fOut.close();

The POI version I use is
jakarta-poi-1.11.0-dev-20030225.jar
Comment 1 Jason Height 2003-02-27 21:11:41 UTC
Upload the excel file as well as providing a small piece of code that uses the 
template to generate the error.
Comment 2 Henning Boeger 2003-03-03 14:30:49 UTC
Created attachment 5118 [details]
Excel file for reproducing the bug
Comment 3 Henning Boeger 2003-03-03 14:37:15 UTC
/*
The following code produces a corrupt(?) excel file by modifying the attached 
template file (using jakarta-poi-1.11.0-dev-20030225.jar).

Note: When opening the resulting "out.xls", Excel does not crash immediately, 
but behaves strangely. I cannot select the sheet, the diagram is empty. If I 
try to change the diagram's source fields, Excel crashes.
*/

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class SimpleExcelTest {
	public static void main(String[] args) throws Exception {
		HSSFWorkbook book = new HSSFWorkbook(new FileInputStream
("template.xls"));
		
		book.removeSheetAt(0);
	
		FileOutputStream fOut = new FileOutputStream("out.xls");
		book.write(fOut);
		fOut.close();
	}
}
Comment 4 Andy Oliver 2003-07-24 15:50:32 UTC
complicated.  put off till 3.0.
Comment 5 Yegor Kozlov 2009-04-17 11:32:19 UTC
The problem is not reproducible with the latest trunk.  

Please try the latest svn version .
Daily builds are available at
http://encore.torchbox.com/poi-svn-build/

Regards,
Yegor