I have code that is exporting to excel and i have an array of columns . .
var colheaders = new string[] {"Name", "Age", "Total", "Date"}
right now i have code that looks like this to setup the headers
excelExport.SetCell("A", 1, "Name");
excelExport.SetCell("B", 1, "Age");
excelExport.SetCell("C", 1, "Total");
excelExport.SetCell("D", 1, "Date");
the issue is that if i have 50 columns and i want to add one at the beginnging, i have to go and updated the letter in each column "A", "B", "C", etc . .
since i have an array already of string headers i would like something like this:
foreach (string colheader in colheaders)
{
excelExport.SetCell("A", 1, colheader);
}
but i need to dynamically set the letter "A" in this case. Something like this:
int i = 0;
foreach (string colheader in colheaders)
{
excelExport.SetCell(GetCol(i), 1, colheader);
i++;
}
NOTE:
Also, after Z, i need to go to AA, then AB, then AC, etc . . to match the Excel columns so the logic would have to go beyond 26 columns