Incorrect double value with PutValue function

Hi All
I'm programming in .Net and using Aspose dll version 5.3.0.0.
I Have a problem because I'm trying to put in a cell a big double value, I save file. Now when I open a saved file, I view in a cell a very different value. In my case I'm trying to insert the value 900000000,00 and saving and opening rhe file the value the cell is a negative value like -173000000


The code is:
Aspose.Cells.Worksheet oSheet;
...
oSheet.Cells[dbCell].PutValue(Double.Parse(oDr["Valore"].ToString()));
...
oWB.Save(resFileName);

oDr is a datatable and dbCell is a string variable that contains the position of a cell (ad es. "G49") Is there any reason about that?
The problem during the test become only trying with big values.

I note that if I save a file immediately after the assignment, the cell already have the incorrect value.
Someone can help me?
Thanks
Emanuele

Hi Emanuele,


Thank you for using Aspose products, and welcome to Aspose.Cells support forum.

As you are using a very old version of the API therefore your presented scenario could be a bug. You can verify this by downloading the latest version of Aspose.Cells for .NET 8.0.0, and give it a try on your end with real time data. Please do skip the statements for licensing the product, because you may experience exception stating that you are not allowed to use the latest version with current subscription.

Moreover, you may also try with Aspose.Cells for .NET 5.3.0.0 by passing a second parameter (of Boolean type) to the PutValue method. Setting the last parameter to TRUE, will auto convert the string value to the appropriate Excel data type before setting it as a cell value. Please check the below code snippet for your reference.

C#

oSheet.Cells[dbCell].PutValue(oDr[“Valore”].ToString(), true);

First of all thanks for the immediate suggestion tu try the code:

oSheet.Cells[dbCell].PutValue(oDr["Valore"].ToString(), true);

I try but the result it is the same, the value of cell continue to be -173741824.
I also tried to put 19000000,0 instead 900000000,0, saving the file and try to open it. Now the value is correct. Why that?
Yesterday I have downloaded the trial version 8.0.0, now if I can modify the application, I'll test it.
If you have any other suggestion, please tell me.
Thanks
Emanuele

Hi Emanuele,


Sorry to know the provided solution didn’t work for you.

I have tested the presented scenario against the latest version of Aspose.Cells for .NET 8.0.0, and have received expected results. Setting the Cell value as “900000000.00” resulted in a corresponding number, whereas setting the Cell value as “900000000,00” resulted in a general format entry. I believe the comma “,” in your provided string is actually a decimal separator, could you please try by replacing it with a dot “.”?

I also tried to enter "900000000", "900,000,000.00" and "900,000,000.00", the comma or point simbol dipend Info culture setting. In any case, the result is always the same value in the cell (-173 741 824).

We also noticed that the problem does not occur if the before cell is not valued,
In this case the cell is the "G48", if the "F48" is enhanced, the value of the "G48" is wrong, if the "F48" instead of the empty cell "G48" has the correct value. What could be the cause? might be some setting for the style of the cell?

The extract after saved report are:

900.000.000 Sm3

1 -173.741.824 Sm3


As I said before, it is very strange behavior because with values ​​as large as 19000000 cell, after saving the file, it appears with the correct value.

The main problem is that these erroneous values ​​then are used in formulas, operations and in this way the final result is wrong.

I think it might be a bug as overflow or something like that. No one else has had the same problem? I'm the first?


Thanks for availability
Emanuele

Hi Emanuele,


Sorry to know none of the above mentioned solutions worked for you. Now its quite confirmed that the presented scenario is a bug in your current version of the API therefore you have to upgrade your project to accommodate Aspose.Cells for .NET 8.0.0. Please let us know if you need our further assistance.