关于asp.net导出excel的注意(3)
当导出excle时,如果数据不多,中文能正常显示,如果数据太多,中文变乱码
Response.AppendHeader("Content-Disposition", "attachment;filename=" + "result.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");
this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
grdList.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
把utf-8改成utf-7就一切正常了。具体原因不明
浙公网安备 33010602011771号