下载后打开XLSX文件时,我收到Excel中的错误消息:
我们发现' filename.xlsx '中的某些内容存在问题。你想让我们尽可能多地恢复吗?如果您信任此工作簿的来源,请单击“是”。
当我在服务器上检查文件时,我在Excel中没有出现任何错误。
我正在使用ASP.NET将文件发送给用户,如下所示:
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AppendHeader("Content-Disposition", "Attachment; filename=\"filename.xlsx\"");
Response.AppendHeader("Content-Length", File.ReadAllBytes(xlsxFilepath).Length);
Response.TransmitFile(xlsxFilepath);
Response.End();
}
此问题仅在我更换服务器时才开始发生。
答案 0 :(得分:0)
我需要在Response.Flush()
之前Response.End()