Asp.NET导出Excel文件乱码解决方法

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "GB2312";
this.Page.Response.Write("<meta http-equiv=Content-Type content=\"text/html;charset=GB2312\">");//解决乱码问题
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("日常保养记录" + ".xls"));
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType = "application/ms-excel";

HttpContext.Current.Response.Write(this.outputstr.Value);//写入excel
HttpContext.Current.Response.End();

 

posted on 2012-03-31 12:08  zhuhai  阅读(213)  评论(0编辑  收藏  举报

导航

我的百度空间