I have an excel table with column headers, and I don't want to hardcode the letter or index of the column, so I'm trying to figure out how I can make it dynamic. I am looking for something like this:
var ws = wb.Worksheet("SheetName"); var range = ws.RangeUsed(); var table = range.AsTable(); string colLetter = table.GetColumnLetter("ColHeader"); foreach (var row in table.Rows()) { if (i > 1) { string val = row.Cell(colLetter).Value.ToString(); } i++; }
Does ClosedXML support something like the created GetColumnLetter () function above, so I donβt need to write the letters of a column with hard code?
source share