Response.Clear();
Response.Buffer= true;//设置缓冲输出
Response.Charset="GB2312";//设置输出流的HTTP字符集Response.AppendHeader("Content-Disposition","attachment;filename=\""+System.Web .HttpUtility.UrlEncode (staticObject.queryname ,System.Text .Encoding .UTF8 )+"."+leixing+"\"");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/ms-"+leixing1+"";
this.EnableViewState = false;//是否保持视图状态System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); //将信息写入字符串
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); //在WEB窗体上写出一系列的HTML特定字符和文本
this.DataGrid1.RenderControl (oHtmlTextWriter);
Response.Write(oStringWriter.ToString ());
Response.End ();
////////////////////////////////////////////////////////////////
当结果集中有中文时,在页面的DATAGRID中 显示都是好的,可当下载成EXCEL,有时会出现中文乱码,请高手指教!!!
Response.Buffer= true;//设置缓冲输出
Response.Charset="GB2312";//设置输出流的HTTP字符集Response.AppendHeader("Content-Disposition","attachment;filename=\""+System.Web .HttpUtility.UrlEncode (staticObject.queryname ,System.Text .Encoding .UTF8 )+"."+leixing+"\"");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
Response.ContentType = "application/ms-"+leixing1+"";
this.EnableViewState = false;//是否保持视图状态System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); //将信息写入字符串
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); //在WEB窗体上写出一系列的HTML特定字符和文本
this.DataGrid1.RenderControl (oHtmlTextWriter);
Response.Write(oStringWriter.ToString ());
Response.End ();
////////////////////////////////////////////////////////////////
当结果集中有中文时,在页面的DATAGRID中 显示都是好的,可当下载成EXCEL,有时会出现中文乱码,请高手指教!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货