Writing Excel using EPPLUS not workable after deployed

筅森魡賤 提交于 2019-12-11 07:03:54

问题


I'm using EPPlus to generate excel (.xlsx) in my mvc3 web application. It works fine with my localhost. However, after i deployed to the server, the excel file return as an Excel Binary Workbook. Can anyone help me?

Here is how i generate my excel (.xlsx):

    ExcelPackage pck = new ExcelPackage();
    ExcelWorksheet ew = pck.Workbook.Worksheets.Add("template" + templateVM.Year);

    List<YieldsTemplate> list = mgr.GetTemplates(templateVM.Year);

    ew.Cells["A1"].LoadFromCollection(list, true);
    ew.Cells["A:AZ"].AutoFitColumns();

    Response.Clear();
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("content-disposition", "attachment: filename=" + "abc" + ".xlsx");
    Response.BinaryWrite(pck.GetAsByteArray());
    Response.End();

thank you!!

来源:https://stackoverflow.com/questions/51412740/writing-excel-using-epplus-not-workable-after-deployed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!