I’m using C# to read an excel sheet and use the following code to read the values:
range = xlWorkSheet.UsedRange;
object value = (range.Cells[rCnt, cCnt] as Excel.Range).get_Value(Type.Missing);
In case an integer number appears there (for example 2), then it shows me as float: 2.0
How could I know if it’s an float or integer there?
More than that, how could I know if a string is stored in the cell, or integer or float?
Thanks
Moti
I am not sure is Excel makes difference between integers and floats — you can enter 1 to cell and then move decimal point making it look like 1.00.
To figure out whether it is integer or not you may try the following:
float.TryParse()is also there 🙂