0

I am using POI to read an excel. In some point I read a cell

while(rowIterator.hasNext()) { //read the rows
    Row row = rowIterator.next();
    String quantity = row.getCell(4).toString(); // it returns a string in 1000.0 
}

Why I get a string 1000.0 and not 1000 ? The values in the excel are in General format, without the . e.g 1000, 234, 33, 102 etc..

yaylitzis
  • 5,354
  • 17
  • 62
  • 107

1 Answers1

2

Using toString() method on cell will return the String representation of the cell value. If you are sure your cell will return Number then you should use getNumericCellValue() on cell.

i.e

row.getCell(4).getNumericCellValue()
Pragnani
  • 20,075
  • 6
  • 49
  • 74