I have a VSTO addin and I'm reading data from an Excel worksheet.
It seems that almost all numeric data is read as a double
. Is it ever possible to get an int
value from Range.Value
?
Here is some code to demonstrate what I mean.
Worksheet w = (Worksheet)Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets["Sheet1"];
var value = ((Range)w.Cells[1, 1]).Value;
bool isInt = value is int;
bool isDouble = value is double;
No matter which format I use in worksheet Sheet1, cell A1, isInt
always comes back false.
Is there some format I should be using to get int
? I thought maybe General
or 0
would work, but it seems not.