After the C # Web download files directly into excel file download error problem

Download the code is as follows:

System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
System.Web.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12";
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + outputFileName);
System.Web.HttpContext.Current.Response.BinaryWrite(oByte);
//清除缓存
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();

It is labeled red code key error, should read:

System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";

Guess you like

Origin www.cnblogs.com/chensong0524/p/12176110.html