How to best fetch a cell value from excel using VSTO?
- by Behrooz Karjooravary
I am trying to get cells from excel into csharp but not sure what's the best variable type to read it into.
If I make the variable a string and the cell value is a double I get a parse error. If I make the variable double then when the cell is a string it wont work.
Here's the code I am running:
try
{
string i = Globals.Sheet1.Cells[7, 7].Value;
double num;
if (i == null) return;
if (double.TryParse(i, out num))
{
.
.
.
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}