使用EPPlus在MVC中下载Excel文件的XML错误

时间:2015-06-29 15:25:31

标签: c# ajax epplus

这是重要的部分,从视图中的AJAX调用调用:

 using (ExcelPackage pck = new ExcelPackage())
        {
            ExcelWorksheet ws = pck.Workbook.Worksheets.Add(fileName);
            ws.Cells["A1"].LoadFromDataTable(dt, true);
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment;  filename=" + fileName + ".xlsx");
            Byte[] bytes = pck.GetAsByteArray();
            Response.BinaryWrite(bytes);
            Response.End();
        }

但它会产生错误: enter image description here

知道出了什么问题吗?

0 个答案:

没有答案