2016-02-23 21 views
0

我正在使用POI来读取excel。在某些时候,我读了细胞Excel中的数字以双数形式返回

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

为什么我得到一个字符串1000.0而不是1000? excel中的值为通用格式,不含.,例如1000,234,33,102等。

回答

2

在单元格上使用toString()方法将返回单元格值的字符串表示形式。 如果您确定您的手机将返回号码,那么您应该在手机上使用getNumericCellValue()

row.getCell(4).getNumericCellValue() 
+0

太好了! thx的信息! – yaylitzis

相关问题