Hi Aspose team,
Let’s have the attached input.xlsx file and read the Value and DisplayStringValueproperties of the cell V154 which value in excel is 0.00, with the following C# code:
var excelDoc = new Workbook(“TestFiles\input.xlsx”);
var value1 = excelDoc.Worksheets[0].Cells[“V154”].Value.ToString();
var displayValue1 = excelDoc.Worksheets[0].Cells[“V154”].DisplayStringValue;
We we’ll obtain value1=1.77635683940025E-15, which is not correct. The real value is 0. DisplayValue in this case is correct = 0.00
Note:
If we change, in the excel, the format of this cell (V154) to 30 decimals - see the second attached excel: input1.xlsx and run the same code for the second excel file:
var excelDoc = new Workbook(“TestFiles\input1.xlsx”);
var value2 = excelDoc.Worksheets[0].Cells[“V154”].Value.ToString();
var displayValue2 = excelDoc.Worksheets[0].Cells[“V154”].DisplayStringValue;
The both values are 0 now. Why in the first case we obtain 1.77635683940025E-15 instead of 0.
Internal ID: 48525
Thanks,
Vitalie Semenciuc
Senior Software Developer
IBM Romania
Hi Vitalie,
Hi,
Hi,
This option (with CalculationOptions.PrecisionStrategy) was introduced from version 8.5 version of the Aspose.Cell, as I know. Beginning with this version we started to have the issue with precision described above.
Indeed, I tried this option and it works (it works with CalculationPrecisionStrategy.Decimal and CalculationPrecisionStrategy.Round and it doesn’t work with CalculationPrecisionStrategy.None).
My question is what parameter (Round or Decimal) did you use before this new option ?
We have to change CalculateFormula() method in a lot of places in our application and we want to be sure that this new parameter won’t affect the old implementation.
Thanks a lot,
Vitalie Semenciuc
Senior Software Developer
IBM Romania
Hi,
Hi,
Thanks for using Aspose.Cells.
By our test, no one strategy can work fine for all cases. As we have
said, it seems ms excel uses different strategies for different
situations but we don’t know how ms excel decides which strategy should
be used for one formula. In previous versions, we use different strategy
for some special cases with special conditions. And we also found the
old logic cannot work fine for some users’ cases. So we move the
strategy out of the special formula and make it as a common option for
user to decide which one should be used. Maybe the old special logic can
work for your special case, but there must have other cases for which it
cannot work.
Also as we said, by our test the default strategy NONE is the most suitable one for most cases. To change the strategy for all your cases, you need to test it for your existing cases to make sure the new strategy can work for you.
Hi,
Thanks for your posting and using Aspose.Cells.
We have logged your comment in our database for product team consideration and investigation. We will look into it and update you. Once, there is some news for you, we will let you know asap.
Hi Ruzandra,
ibmromania:We’re thinking of using CalculateFormula with the Round CalculationPrecisionStrategy in certain scenarios. If my understanding is correct this strategy is about rounding a number to a certain number of decimals (the precision) - is this strategy customizable - meaning the number of decimals?
I am afraid, the current implementation of CalculationPrecisionStrategy does not provide the ability to round a number to specified precision when calculating formulas. Moreover, the said feature is not on the road map of Aspose.Cells APIs.
Thank you for your understanding.
Hi,
Hi,