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
Upload the excel file as well as providing a small piece of code that uses the template to generate the error.
Created attachment 5118 [details] Excel file for reproducing the bug
/* 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(); } }
complicated. put off till 3.0.
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