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?
Craig MurphyPosted May 5, 2006, 6:58 AM
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
aparna gollaproluPosted May 4, 2006, 6:35 PM
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