I have an excel file that contains the names of the columns in the first row. How can I find the number of the last non-empty column in the first row? I use the library ClosedXML.Excel;
Asked
Active
Viewed 2,058 times
1 Answers
3
Try this:
var workbook = new XLWorkbook(fileName);
int col = workbook.Worksheet(1)
.Row(1)
.LastCellUsed()
.Address
.ColumnNumber;

Connell.O'Donnell
- 3,603
- 11
- 27
- 61