I have a problem with looping through an excel file. I want to be able to create an automatic code that will handle multiple excel files
There is a fix header in each file, so the "real" datas begin at line 15.
I'm trying to use "usedRange" but I don't really understand the doc.
Actually, I have this :
var excel = new Excel.Application();
var wkb = OpenBook(excel, _myExcelFile, true, false, false);
var sheet = wkb.Sheets["B.C"] as Excel.Worksheet;
var usedRange = sheet.UsedRange;
var i = 0;
foreach (Excel.Range row in sheet.UsedRange.Rows)
{
i++;
// I get data like this (for column 2 for example) :
// Convert.ToString(row.Cells[i, 2].Value);
}
Problem is that my excel file have over 3000+ rows, but the loop returns only 1800+, I can't figure why.
I think that there is a problem with the "UsedRange" function but don't know why.
How can I loop ALL rows in my file?