Write Long Set Of Headers To Excel Using EPPlus

303 Views Asked by At

I'm using EPPlus to write data to Excel, which works great. I'm writing a header row from column A to column AI and am using the code below to write the data

(subset of the code)

using (ExcelPackage pck = new ExcelPackage())
{
    ExcelWorksheet ws = pck.Workbook.Worksheets.Add(customer);
    ws.Cells["A1"].Value = "First Name";
    ws.Cells["B1"].Value = "Last Name";
    ws.Cells["C1"].Value = "Address1";
    ws.Cells["D1"].Value = "Address2";
    ws.Cells["E1"].Value = "City";
    ws.Cells["F1"].Value = "State";
    ws.Cells["G1"].Value = "Zip";
    ws.Cells["H1"].Value = "Phone";
    
    //keep writing data to I, J, K, L, etc
    
    ws.Cells["AF1"].Value = "Hire Date";
    ws.Cells["AG1"].Value = "Manager Name";
    ws.Cells["AH1"].Value = "Manager Hire Date";
    ws.Cells["AI1"].Value = "Simlcam Number";

    FileInfo fi = new FileInfo("C:\\Test\\EPPlusWorkbook.xlsx");
    await pck.SaveAsAsync(fi);
}

Now this code writes headers perfectly, UNTIL it reaches cell AF1 then for whatever reason the no further header info is written to the workbook.

Stepping thro the code shows that the lines of code are hit so there is no error displayed.

0

There are 0 best solutions below