Removing worksheets in MS Excel file in Java

Hello.

I have some troubles with method workbook.getWorksheets().removeAt

workbook.getWorksheets().insert(0, 1);
//Some complex actions with book (copy ranges from this book to another, etc)
workbook.getWorksheets().removeAt(0);

When we calls method removeAt, code thrown following exception.

com.asuproject.usoi.report.ReportConstructionException: java.lang.NullPointerException
at com.aspose.cells.b.a.c.a(Unknown Source)
at com.aspose.cells.b.a.c.a(Unknown Source)
at com.aspose.cells.bjr.a(Unknown Source)
at com.aspose.cells.sz.a(Unknown Source)
at com.aspose.cells.ChartCollection.a(Unknown Source)
at com.aspose.cells.NameCollection.a(Unknown Source)
at com.aspose.cells.NameCollection.a(Unknown Source)
at com.aspose.cells.WorksheetCollection.removeAt(Unknown Source)
at com.asuproject.util.adapter.aspose.AsposeBookAdapter.deleteSheets(AsposeBookAdapter.java:556)

Can you please check your components for this exception.
Unfortunately we can't reproduce this bug in test cases, just in application
At this moment we have used temporary license.

Hi Alexey,

Thank you for considering Aspose products.

Please give a try to latest version of Aspose.Cells for Java (Download Section) on your end, and see if the latest version resolves your problem. In case the problem persists, we need your complete source code as well as the template file (if any) to replicate the problem on our end. Once the issue has been reproduced, we can quickly move forward to fix it for you.

Hi. I have found possible test case

@Test
public void deleteWorksheetTest() {
String fileName = "ChartTest.xlsx";
try {
Workbook workbook = new Workbook("D:\\" + fileName);
workbook.getWorksheets().insert(0, 0);
workbook.getWorksheets().removeAt(0);

workbook.save("D:\\rs1"+fileName);
} catch (Exception e) {
e.printStackTrace();
}
}

Can you say me - what wrong with file? (Another files works correctly)

Best regards. Alexey

Thanks for quick reply. We have used already latest version


I have added testcase above.

Best regards.

Hi Alexey,

Thank you for providing your template file.

You are right, the issue is template specific as we are unable to reproduce the exception with other spreadsheet files. An investigative ticket (CELLSJAVA-40676) has been logged in our bug tracking system to properly analyze the issue on our end, and to provide a fix (if applicable). We will keep you posted with updates in this regard.

Hi,



Please try the latest version/fix: Aspose.Cells for Java (Download Section).
We have fixed your issue now.



Let us know your feedback.

Thanks,

Many thanks!


Best regards. Alexey

Hi,


We hope that your issue is fixed by the new fix/version. We have tested your scenario/ case on our end, it works fine here.

If you still find any issue, let us know.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-40676) have been fixed in Aspose.Cells for Java (Download Section).


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.