在导出的xlsx文件中显示警告消息

时间:2018-05-04 08:49:20

标签: c# asp.net asp.net-mvc excel

我的xlsx文件已下载,但当我打开该xlsx文件时,它会显示警告

  

'我们发现某些内容存在问题。

有人能告诉我在哪里解决这个问题吗?我正在使用iFrame下载文件。

using (ClosedXML.Excel.XLWorkbook wb = new XLWorkbook())
{
     wb.Worksheets.Add(dt, "Sheet1");
     Response.Clear();
     Response.Charset = "";
     Response.Buffer = true;
     Response.BinaryWrite(bytes);
     Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
     Response.AddHeader("content-disposition", "attachment;filename=" + >Model.reportName + "_" + DateTime.Now.ToString("yyyyMMddHH:mm") + "." + extension);
     using (MemoryStream MyMemoryStream = new MemoryStream())
     {
       wb.SaveAs(MyMemoryStream);
       MyMemoryStream.WriteTo(Response.OutputStream);
       Response.Flush();
       Response.Close();
       HttpContext.Current.ApplicationInstance.CompleteRequest();
     }

0 个答案:

没有答案