I have cell "A1" with a value of 1.00 given by the formula
I want to store this value in a variable.
I tried:
ws.Cells["A1"].Value
ws.Cells["A1"].Text
ws.Cells["A1"].GetValue<double>
ws.Cells["A1"].Value.ToString()
None of these functions work, because I either get an error message or don’t get my number at all (console.writeline displays a space).
I tried searching on the internet and I get what I tried above. I know that I am referencing the cell correctly, because I can really set the value simply.
So, how do I get my value of 1.00 and store it in a double variable?
EDIT: my code where the worksheet in the path file has a value of "A1" 1.00
using (var pck = new ExcelPackage(filePath))
{
var ws = pck.Workbook.Worksheets[1];
var test1 = ws.Cells["A1"].Value;
var test2 = ws.Cells["A1"].Text;
var test3 = ws.Cells["A1"].GetValue<double>();
Console.WriteLine(test1);
Console.WriteLine(test2);
Console.WriteLine(test3);
}
:
[blank]
[blank]
0
EDIT2: value 1.00 is the formula
source
share