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);
Add Properties like { get; set;}
for each variable, because the way epplus works is on properties of class.
For example, instead of using:
class student
{
int num;
string name;
}
use this:
class student
{
int num { get; set; }
string name { get; set; }
}
This is a bug in EPPlus library and it has been reported on September 25, 2017.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With