Null Reference Exception when saving list of numbers.
bradykelly opened this issue · comments
Brady Kelly commented
If I run the following code, my workbook gets saved nicely, with a short list of year numbers:
` {
using (ExcelPackage pck = new ExcelPackage(new FileInfo(TheFile)))
{
var listSheet = pck.Workbook.Worksheets.Add("LISTS");
listSheet.Cells["E1"].Value = "Heading";
for (var i = 2; i < 10; i++)
{
listSheet.Cells[$"E{i}"].Value = (DateTime.Now.Year - i);
}
pck.Save();
}
}`
If I remove the code listSheet.Cells["E1"].Value = "Heading";
, then pck.Save();
fails with a Null Reference Exception. EPPlus doesn't like columns of numbers without a header.