Reputation: 4425
I am trying to create an excel file using Epplus package. I am doing this
static List<TestData> list = new List<TestData>
{
new TestData
{
Name = "Mohsin",
Number = 1
},
new TestData
{
Name = "Ali",
Number = 2
}
};
I am then calling this function
sheet.Cells["A1"].LoadFromCollection(list, true);
I saves the correct data to the file but missing headers and I want the members of my class to be the header here. Is there a way I can achieve it without hard coding? As I would be calling it from various different types of object types?
Upvotes: 0
Views: 903
Reputation: 3260
It's working for me like this:
sheet.Cells["A1"].LoadFromCollection(Collection: res, PrintHeaders: true);
also you may like this:
sheet.Cells["A1"].LoadFromCollection(list, true);
Probably you have some missing in your output file.
Upvotes: 0