I'm dealing with excel files in a C# application.
I'm wondering why this code doesn't work:
var value1 = ws.Range[ws.Cells[7,4]].Value;
For now I found that this works fine:
int i = 7;
var value1 = ws.Range["D" + i.ToString()].Value;
Because you cant pass to a Range() a single Cells() Property, you will need to set it with 2 parameters of Cells():
var value1 = ws.Range[ws.Cells[7,4],ws.Cells[7,4]].Value;
or (use strict the Cells Property):
var value1 = ws.Cells[7,4].Value;
The first parameter of ws.Range[] should be in in A1-style notation
To access
ws.Cells[7,4]
you can try this code:
var value1 = ws.Range["D7"].Value;
And check out this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With