Decimal places returned by Cell getStringValue()

When I run the following code:


public static void main(String[] someArgs) throws Exception
{
Workbook workbook = new Workbook();

WorksheetCollection worksheets = workbook.getWorksheets();

int sheetIndex = worksheets.add();

Cells cells = worksheets.get(sheetIndex).getCells();

double myValue = 7.186180643663701;
cells.get(“A1”).setValue(myValue);

System.out.println(myValue);
System.out.println(cells.get(“A1”).getStringValue());
System.out.println(cells.get(“A1”).getDoubleValue());
System.out.println(cells.get(“A1”).getValue());
}

I get the following output:

7.186180643663701
7.18618064196875
7.186180643663701
7.186180643663701

Why does getStringValue not only return a truncated value, but also a value that is different from the 8th decimal place onwards?

I’m running within NetBeans on Mac as follows:


Product Version: NetBeans IDE 6.9.1 (Build 201011082200)



Java: 1.6.0_26; Java HotSpot™ 64-Bit Server VM 20.1-b02-384



System: Mac OS X version 10.6.8 running on x86_64; MacRoman;
en_US (nb)


Hi,

Thanks for reporting.

I was able to replicate this issue using the latest version:
Aspose.Cells for Java v7.0.1.5

We have logged this issue in our database. Once the issue will be fixed or we get some update, we will let you know asap.

This issue has been logged as CELLSJAVA-31050.

Hi,

Please download: Aspose.Cells for Java v7.0.1.6

Currently we do not support to truncate decimal value as ms excel for cell.getStringValue(). However we have fixed the issue of "value that is different from the 8th decimal place onwards”. Because precision of floating-point values, "7.186180643663702” will be returned by Cell.getStringValue() for given double value “7.186180643663701”. We will make enhancements for Cell.getStringValue() to make it same with what shown in ms excel in later versions when we have enough time.

The issues you have found earlier (filed as 31050) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.