Search code examples
epplus

EPPlus: "Column out of range" error with LoadFromCollection


I am getting a "Column out of range" error with LoadFromCollection - code follows. Insert into the SampleApp that comes with EPPlus to replicate.

Did I do something screwy or is it a bug? Or a config setting that I haven't set?

public class tst
    {
        public string Name;
        [Description("Created Time")]
        public DateTime Created_time;
    }


     var pck = new ExcelPackage();

            var kpcollection = new List<tst>();
            for (var i = 1; i <= 10; i++)
            {
                kpcollection.Add(new tst
                {
                    Name = "line" + i.ToString(),
                    Created_time = DateTime.Now
                });
            }

            var wsenum = pck.Workbook.Worksheets.Add("KPTest");
            //Load the collection starting from cell A1...
            wsenum.Cells["A1"].LoadFromCollection(kpcollection, true, TableStyles.Medium9);

Solution

  • This is a bug in EPPlus library and it has been reported on September 25, 2017.