C#下载office .xlsx文件后打不开,改为.xls可以打开,有没有办法解决
curContext.Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8) + ".xlsx");
curContext.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
curContext.Response.ContentEncoding = System.Text.Encoding.UTF8;
curContext.Response.Charset = "GB2312";
strWriter = new StringWriter();
htmlWriter = new HtmlTextWriter(strWriter);
dgExport = new GridView();
dgExport.DataSource = dtData.DefaultView;
dgExport.AllowPaging = false;
dgExport.DataBind();
dgExport.RenderControl(htmlWriter);
curContext.Response.Write(strWriter.ToString().ToCharArray(), 0, strWriter.ToString().ToCharArray().Length);
curContext.Response.End();