这是重要的部分,从视图中的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();
}
但它会产生错误:
知道出了什么问题吗?