1

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;

RobinВricks
  • 93
  • 1
  • 1
  • 10

1 Answers1

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