Detect value type by setting cell value as string with Cell.PutValue using Aspose.Cells for .NET in C#

Is there no way to put a value in a cell and let Excel determine what type of value it is? (just like as if the user had typed it into the cell themselves)

In the database we use, users often store numeric or date data in string fields.


If I was using Excel-Automation, I could simply set the cell’s value to the value in the database (as a string) and Excel would allow it to be “formatted” as a number, currency, or date - whatever the “Cell Format” is.

With Aspose.Excel, when I use PutValue(string), it forces it to be a string in Excel, and the “Cell Format” options don’t work.

I would think this would be a fairly common problem when using Aspose.Excel.



Is there no other way to set the value of a cell to something that isn’t hard-typed? Something like PutGenericValue(“1234”) that actually lets excel use the cell as a numeric value?

Jordan

Hi Jordan,

Thanks for your suggestion.
I will add a new overloaded PutValue method to serve your need. This method will be PutValue(string stringValue, bool isConverted).

This new method surely will be slower than previous PutValue method but it will be more flexible.