How to best fetch a cell value from excel using VSTO?
Posted
by
Behrooz Karjooravary
on Stack Overflow
See other posts from Stack Overflow
or by Behrooz Karjooravary
Published on 2010-12-03T01:50:24Z
Indexed on
2011/01/01
6:54 UTC
Read the original article
Hit count: 348
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());
}
© Stack Overflow or respective owner