I am trying to loop through a range and write values into the cells of that range. I'm getting an exception when giving the instantiated range an actual value.
what am I doing wrong?
int fieldcount = dr.FieldCount;
for (int f = 0; f < fieldcount; f++) {
Excel.Range chartRange;
int count = 1;
chartRange = sheet.Range["B43:043"];
foreach(Excel.Range cell in chartRange.Cells) {
Debug.Print(cell.Address, cell.Value);
}
}
I've also tried setting the range as follows:
sheet.get_Range("B43", "043");
The exception I'm getting is Exception from HRESULT: 0x800A03EC
I Think you have a typo in your range. "043" (the number 43 with a leading zero) is not a valid cell reference. Are you intending: sheet.Range["B43:O43"] ?
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