小编Waq*_*Ali的帖子

打开使用EPPlus生成的Excel文件时显示错误对话框

我正在使用EPPlus库创建一个Excel文件.当我创建文件并打开文件时,以下弹出消息显示:

我们发现"ExcelDemo.xlsx"中的某些内容存在问题.你想让我们尽可能多地恢复吗?如果您信任此工作簿的来源,请单击"是"

我正在使用以下代码

using (ExcelPackage pck = new ExcelPackage())
{
    //Create the worksheet
    ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

    //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
    ws.Cells[1, 2].Value = "Excel Download";

    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("content-disposition", "attachment;  filename=ExcelDemo.xlsx");
    Response.BinaryWrite(pck.GetAsByteArray());
}
Run Code Online (Sandbox Code Playgroud)

我的代码中是否存在问题或者这是Excel问题?

c# asp.net excel epplus

10
推荐指数
2
解决办法
9555
查看次数

标签 统计

asp.net ×1

c# ×1

epplus ×1

excel ×1