Bug 40829

Summary: file corrupt if sheets with printTitleRows set are removed
Product: POI Reporter: Meikel Bisping <M.Bisping>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: All   
OS: Windows XP   

Description Meikel Bisping 2006-10-27 07:35:26 UTC
Excel 2003 puts out an error message when opening a POI-produced excel workbook
which 
- was created from an existing excel workbook file
- contained sheets with PageSetup.PrintTitleRows set and
- one of those sheets is removed from the workbook before saving.

public class TestRepeatingRowsAndColumns
{
public static void main(String args[]) {
    try {
        test();
    } catch (Exception e) {
        e.printStackTrace();
    }
    
}

public static void test() throws Exception
    {   
             java.io.FileInputStream fis = 
                 new java.io.FileInputStream("test.xls");
//http://www.mbisping.de/test.xls
             org.apache.poi.poifs.filesystem.POIFSFileSystem fs = new
org.apache.poi.poifs.filesystem.POIFSFileSystem(
                     fis);
             HSSFWorkbook wb = new HSSFWorkbook(fs);
                fis.close(); 
             int sheetCount = wb.getNumberOfSheets();
//removing repeating Rows/Cols before deleting doesn't help              
wb.setRepeatingRowsAndColumns(sheetCount-1,-1,-1,-1,-1);   
              
             wb.removeSheetAt(sheetCount-1);
                
             FileOutputStream out = new FileOutputStream("testout.xls");
             wb.write(out);
             out.close();
         
    }
}
Comment 1 Yegor Kozlov 2009-04-18 03:26:24 UTC
The provided link (http://www.mbisping.de/test.xls) is invalid. 

Can you attach the problem file so that we can reproduce the trouble?

Yegor
Comment 2 Dominik Stadler 2014-07-28 18:01:54 UTC
No update for a long time => Resolving this issue.