0
                ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
                var columncount =worksheet.Dimension.Columns;
                
                var rowcount = worksheet.Dimension.Rows;

here is my code, I'm getting number of columns and rows but I want column names

Neelima
  • 1
  • 1
  • put it in a datatable then loop through to get the names https://stackoverflow.com/questions/7662882/get-column-name-from-excel-worksheet – JobesK Sep 14 '22 at 19:00

1 Answers1

0

I want column names

If the column name is in the first row, you can try the following method to get column names :

  var columnname = workSheet.Rows[1].Range.Value;

result:

enter image description here

Qing Guo
  • 6,041
  • 1
  • 2
  • 10