C# Excel Interop and Decimal Places
I am reading in a sheet from Excel using the COM interop library
and .Net 2.0. The sheets themselves will be generated in Excel using
any version from Excel 87 to Excel 2007.
I have run into an issue where numbers appear to be losing their zero
based decimal places: i.e. 45.00 becomes 45 and 45.10 becomes 45.1.
We have asked the clients filling in these sheets to use a specific
number of decimal places - so they are entering 45.00 - but I am not
capturing that.
Right now I am grabbing a range and reading it into an object array.
When I look at the values in the range I even see 45.00 from the sheet
as 45.0. As soon as I ToString() the value ( I have too the database
is all varchar and I have no control over this) - I even lose the .0
and have just 45.
Right now I am reading a range into an object:
object[,] values = (object[,]) rng.Value2;
Is there another way to approach this problem? I can always assume
that 45 = 45.00 but I would rather be able to grab exactly what they
enter - so if they aren't doing it properly we can catch it.
Thanks,
Matt
|