NullPointerException after deleting a worksheet

When you make a copy of a worksheet, you will get an exception if you try to delete that original sheet later. I have a template with one formatted worksheet. I use that sheet as a formatted original and make several copies of it. (Same data layout, separate sheets for different origanizations.) At the end of the process, I need to delete the original sheet.

    public static void testRemove() {
    // Create the Excel workbook
    Workbook wkb = new Workbook();        

    Worksheets sheets = wkb.getWorksheets();
    Worksheet wks = sheets.getSheet(0);
    wks.getCells().getCell(0, 0).setValue( "CELL A1" );

    // new sheet
    wks = sheets.getSheet( sheets.addCopy(0) );
    wks.getCells().getCell(0, 0).setValue( "new Data" );
    
    <B>// PROBLEM: NullPointerException on Workbook.save()
    sheets.removeSheet( 0 );</B>

    // Save the workbook
    try { 
        wkb.save( "C:/TEST_REMOVE.xls" );
    }
    catch(Exception e) {
         System.out.println("Exception class: " + e.getClass());
         
         Throwable cause = e.getCause();
         if( cause != null )
             System.out.println("cause: " + cause.getClass());
    }
}

Our developers are on their Chinese National Day holidays so this issue will be checked at the start of next week. Thanks for your patience.

By the way, are you using the latest v1.7.3?

Hi,

Please try this fix. The fixes of moveSheet and pivotTable are included.

Worked perfectly. Thanks.