To people who use SpreadSheet getSelectedCellReferences() method:
If an empty Cell that is selected by getSelectedCellReferences() method, it will retuen a Set with null reference.
To select Excel Cells has been created within Orignal Excel File, by looping through the Set, it will retuen
spreadsheet.getCell(reference).getCellType() == Cell.CELL_TYPE_BLANK
However if a selected Excel Cells has not been created within excel file, by looping though the Set, it will return
spreadsheet.getCell(reference) == null
Therefore checking if it is Null is important in the code otherwise it will get Error Message like.
SEVERE [com.vaadin.server.DefaultErrorHandler]
(default task-16) : java.lang.NullPointerException
Here is my example of Code,
Set<CellReference> cReferences=spreadsheet.getSelectedCellReferences();
if (cReferences != null) {
for (CellReference reference : cReferences) {
if (spreadsheet.getCell(reference) != null) {
if (spreadsheet.getCell(reference).getCellType() == Cell.CELL_TYPE_BLANK) {
System.out.println("Blank");
} else if (spreadsheet.getCell(reference).getCellType() == Cell.CELL_TYPE_ERROR) {
System.out.println("Error");
} else if (spreadsheet.getCell(reference).getCellType() == Cell.CELL_TYPE_STRING) {
System.out.println(spreadsheet.getCell(reference)
.getStringCellValue());
}
}
}
}