i need to retrieve a single cell instead of Excel.Range in my method.
using Excel = Microsoft.Office.Interop.Excel;
...
public object vReadNumber(Excel.Range targetRange)
{
...
Doing Something With targetRange
...
}
any idea?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Excel.Range.Count property reports how many cells are in the range. For example:
The Excel.Range.Cells[,] indexer returns any cells from the first area of the range. But note that Excel uses base 1 indexing (not base 0). So to access the top-left cell of the range, you could use:
Note that you have to cast to Excel.Range in the above because the Excel.Range.Cells[,] indexer returns an Excel.Range object cast as System.Object.
You should also beware that the Excel.Range.Value property will return an atomic value such as a double, string, boolean, etc. when the range consists of a single cell. It will return a two-dimensional base 1 array, however, if the first area of the range consists of more than one cell. For example:
Hope this helps!
Mike