C# and Excel question
Hello all,
I am reading into a listview Excel spread sheets.
Using the line:
for (int i = 3; i <= 1000; i++) //to loop to 1000 lines
Because of varying number of lines per worksheet, how can I read to "end of data"?
Another problem I am having is trying to read only certain columns i.e. columns A-F, J-M
using : Excel.Range range = worksheet.get_Range("A"+i.ToString(),"O"+i.ToString());
Im working.
Any suggestions to read individual columns?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

aparna gollaprolu4 reputationPosted May 4, 2006, 2:35 PM EDT
I am also facing same kind of problem for reading the data of individual columns and generating charts for that data . any suggetions please help
Thanks-Aparna
Craig MurphyRank #2,956 · 488 reputationPosted May 5, 2006, 2:58 AM EDT
I would suggest that you use a while loop to iterate over your spreadsheet data.
Given that Worksheets have a Cells property, you could write something like this:
[Untested]
int row = 2;
int col = 1;
Excel.Range cell = (Excel.Range) excelWorksheet.Cells[row, col];
while (cell.Value2 != "end of data")
{
cell = (Excel.Range) excelWorksheet.Cells[row, col];
// do something
row++;
}
HTH