We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Incorrect output when numbers are rounded off in excel

Hello,

I am using Aspose.Cells v8.8.3.

I have created an excel file where numbers are rounded off. When I extract the values of those cells, it doesn't return properly rounded off numbers.

For e.g., In excel file 40.15 is rounded off to 40.2 but Aspose.Cells returns 40.1.
Expected reuslt : It should return 40.2

This issue occures when using Java 1.8, when using Java 1.7 the extracted values are corrrect.

Following sample code is used:
Workbook workbook = new Workbook("D:\\round.xlsx");
String x = workbook.getWorksheets().get(0).getCells().get(0, 0).getDisplayStringValue();
System.out.println(x);

Can you please analyse this issue.

Thanks,
Neha

Hi,

Thanks for your posting and using Aspose.Cells.

We have tested this issue with your sample excel file and sample code and were able to notice the rounding issue as per your description.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41923 - Incorrect output when numbers are rounded off in excel

Hi Neha,


This is to update you that we have looked further into the matter logged earlier as CELLSJAVA-41923. Please note, the said behaviour is caused due to a bug in the DecimalFormat.format for JDK 1.8 with RoundingMode.HALF_UP. You may confirm this using the following simple snippet without involving Aspose.Cells for Java APIs. The output will be 40.1.

Java

DecimalFormat df = new DecimalFormat("#.#");
df.setRoundingMode(RoundingMode.HALF_UP);
System.out.println(df.format(40.15));

Hi ,

Could you please confirm the timeframe when Aspose is planning a fix for this issue.

Looking forward for your kind response.

Regards

Hi there,


Please check our previous response for reference. The said problem has been identified in JDK rather than in Aspose.Cells for Java APIs so we cannot fix it.