We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Delete rows error java.lang.NullPointerException

When I execute this code on different versions,eg:aspose-cells-java-20.1,aspose-cells-java-20.12.In the cells-20.1,it’s ok.but in the cells-20.12,get a null pointer error.

Workbook workbook = new Workbook("test-export.xlsx"); 
WorksheetCollection worksheetCollection = workbook.getWorksheets();
WorksheetCollection worksheetCollection1 = workbook.getWorksheets();
Worksheet workSheet = worksheetCollection1.get(0);
worksheetCollection.removeAt(0);
int sheetIndex = worksheetCollection1.add();
Worksheet newSheet = worksheetCollection1.get(sheetIndex);
newSheet.copy(workSheet);
Cells cells = newSheet.getCells();
cells.deleteRows(15, 20, true);

is there something has changed in the cells-20.12?
test-export.zip (29.7 KB)

@xuerui

We have logged the issue as “CELLSJAVA-43664” in our database for investigations. Once we will have some news for you, we will update you in this topic.

@xuerui,

Please remove the worksheet after copying data from it, as the following codes:

cells.deleteRows(15, 20, true);
worksheetCollection.removeAt(0);

If you call removing worksheet, Aspose.Cells has to remove all cached data in global pools (such string pool , image pool).

Also, as the referred value(s) are removed, NullPointerException is thrown.

Thanks for the reply

@xuerui,

You are welcome.