Decimal value in formula bar differs from getDoubleValue() - xlsx

Hi,


I have 84219.4973106866 as the value in a cell. It is formatted to be a currency with 0 decimal
places and the display string value is “$84,219” as expected. But cell.getStringValueWithoutFormat() or cell.getDoubleValue() returns 84219.49731068664
Where does the digit 4 at the end come from ?

Please explain the above case.


Hi,


Thank you for contacting Aspose support.

I have evaluated your presented scenario while using newer version of Aspose.Cells for Java (Download | Maven) API against a sample of my own. I am afraid, I am not able to see the problem as discussed in your post so please give a try to the latest version on your side. In case the problem persists, please provide the sample spreadsheet and code (if different then below) to replicate the problem on our end.

Java

Workbook book = new Workbook(“C:/temp/book1.xlsx”);
Cells cells = book.getWorksheets().get(0).getCells();
System.out.println(cells.get(“A1”).getDoubleValue());
System.out.println(cells.get(“A1”).getStringValueWithoutFormat());


84219.4973106866 84219.4973106866
Hi,

I tested the attached file (Decimal-data.xlsx) with aspose cells for java 8.6.1 and faced the mentioned issue. The methods getStringValueWithoutFormat() and getDoubleValue() returns 209.50999999999996 for 209.51.


Thanks in advance.




Hi,

Thanks for your posting and using Aspose.Cells.

Internally the value is stored as 209.50999999999996 without format in excel file. If you want to get the formatted value or the value shown by excel then please use Cell.getStringValue() method.

Please check the screenshot showing the internal sheet xml file. As you can see in the screenshot the value is actually stored as 209.50999999999996 and not as 209.51.