0

每当我尝试下载 excel 文件时,它会将其保存为 1997-2003 的 Excel 版本,并且我使用了所有内容类型并且找不到解决方案,因为它仍然将其保存为“xls”而不是“xlsx”。

我有一个具有以下代码的导出方法。

    HttpContext.Current.Response.Buffer = true;
    HttpContext.Current.Response.ClearContent();
    HttpContext.Current.Response.ClearHeaders();
    //HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
    HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
    HttpContext.Current.Response.ContentType = "application/ms-excel";
    HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename = " + fileName);
4

0 回答 0