This project has moved and is read-only. For the latest updates, please go here.

Enumerator skips first column if it's empty


If you have an ExcelRange for a header row, and the first column happens to be empty, the enumerator will skip the first column and cause "index out of range" exception when you loop through the actual data.

For example, if there are 5 columns, with headers: "", "Col2", "Col3", "Col4", "Col5"
The following will end up with a list with 4 values:
sheet.Cells[startRow, startCol, startRow, endCol].Select(c => c.Text).ToList<string>();

var headerRow = sheet.Cells[startRow, startCol, startRow, endCol];
foreach(var cell in headerRow) also skips the first column header if it's empty.