您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

export to Excel from a list with EPPLUS

export to Excel from a list with EPPLUS

What version of EPPlus are you using? I ask because I am surprised it does not throw an error as it does with 4.1.0 which is currently the latest. Maybe an older version is more forgiving.

But to answer you question, if you look at the signature of the final overload of LoadFromCollection that is eventually called you will see this:

public ExcelRangeBase LoadFromCollection<T>(IEnumerable<T> Collection, bool PrintHeaders, TableStyles TableStyle, BindingFlags memberFlags, MemberInfo[] Members)

Notice that Epplus is only looking at memberinfos and not a Fields which is what you object is using. If you change Stock object to this:

class Stock
{
    public string Nif { get; set; }
    public string Proveedor { get; set; }
    public string Coodigo { get; set; }
    public string descripcion { get; set; }
    public string Catalogo { get; set; }
    public string Estadistico { get; set; }
    public decimal StockOn { get; set; }
}

You should see results.

其他 2022/1/1 18:13:51 有536人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶