3

All is in the title.

How can I check if a CELL_TYPE_NUMERIC is empty with POI ? With strings i can use the isEmpty() method but with int I have no ideas (null is not allowed and zero just wont do it).

Thank you in advance.

Shiridish
  • 4,942
  • 5
  • 33
  • 64
fpillet
  • 43
  • 2
  • 8
  • [it might help you](http://stackoverflow.com/a/12067629/1211000) http://stackoverflow.com/a/12067629/1211000 – swamy Aug 23 '12 at 01:32

2 Answers2

5

Empty cells should not have format in POI since there is already a type for empty cells.

To check if the cell is empty you should test if the cell type is Cell.CELL_TYPE_BLANK. Sometimes empty cells do not exist in a Row; they will be null in this case.

halfer
  • 19,824
  • 17
  • 99
  • 186
ArtiBucco
  • 2,199
  • 1
  • 20
  • 26
0

You can check the raw value of the cell

public BigDecimal determinePorpertyValue(XSSFCell cell) {
    String rawValue = cell.getRawValue();
    return rawValue == null ? null : BigDecimal.valueOf(cell.getNumericCellValue());
}
Kerem Baydoğan
  • 10,475
  • 1
  • 43
  • 50