spreadsheet icon indicating copy to clipboard operation
spreadsheet copied to clipboard

Spreadsheet throws exception when deleteRows is called and no cell is selected in the spreadsheet

Open KochTobi opened this issue 2 years ago • 0 comments

The method deleteRows produces a NullPointerException. java.lang.NullPointerException: Cannot invoke "org.apache.poi.ss.util.CellReference.getRow()" because "selectedCellReference" is null

https://github.com/vaadin/spreadsheet/blob/317684df11cdb37c29ca5824afc756584aa714e2/vaadin-spreadsheet/src/main/java/com/vaadin/addon/spreadsheet/Spreadsheet.java#L2357C10-L2357C10

Here, the cell reference of the currently selected cell is used. There is no check for null here, so when no cell is selected, deleting rows is not possible and an exception is thrown. This should not be the case. You should be able to delete rows without selecting a cell first (using a button in the UI or something else that uses the java API).

Vaadin version: 24.1.6 Java Version: 17.0.7 Zulu

KochTobi avatar Nov 24 '23 12:11 KochTobi