In Excel I have these decimal values:
TS | BS |
---|---|
5.60 | 4.10 |
10.00 | 10.00 |
10.00 | 10.00 |
10.00 | 10.00 |
While parsing, it shows different values:
TS | BS |
---|---|
0.1375 | 0.85 |
0.0125 | 0.7125 |
0.0125 | 0.8125000000000001 |
0.0125 | 0.7875000000000001 |
I need to print the exact values.
Here is the code:
Iterator<Row> itr = sheet.iterator();
while (itr.hasNext())
{
Row row = itr.next();
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext())
{
Cell cell = cellIterator.next();
switch (cell.getCellType())
{
case STRING:
System.out.print(cell.getStringCellValue() + "\t\t\t");
break;
case NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
System.out.print(dateFormat.format(cell.getDateCellValue()) + "\t\t\t");
} else {
System.out.print(cell.getNumericCellValue() + "\t\t\t\t");
}
break;
default:
}
}
System.out.println("");
}
I'm using Apache POI-4.1.1.
Could please someone help me with this?