currently i'm doing this:
string cellValue = sheet.get_Range("A12", _missing).Value2.ToString();
this works but i really need to select a cell by row and column index.
i get a null exception when i try
string cellValue = ((Range)sheet.Cells[row, column]).Value2.ToString();
any ideas?
=LEFT(B1,2) to extract the first 2 characters of the cell B1. =RIGHT(B1,8) to extract the last 8 characters of the cell B1. =MID(B1,4,2) to extract the 2 characters following the 4th character in B1. To apply the changes to the cells below, drag down the blue square.
The reference form of the Excel INDEX function returns the cell reference at the intersection of the specified row and column. reference - is one or several ranges. If you are entering more than one range, separate the ranges by commas and enclose the reference argument in parentheses, for example (A1:B5, D1:F5).
Where does the ArgumentNullException
occur? Try separating out your code like this and step through it:
object rangeObject = sheet.Cells[row, column];
Range range = (Range)rangeObject;
object rangeValue = range.Value2;
string cellValue = rangeValue.ToString();
This will show you where the null object is.
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