日期:2014-05-19  浏览次数:20450 次

导出到EXCEL中文文件名是乱码问题?
Response.Clear();
                Response.Buffer   =   true;
                Response.Charset   =   "UTF-8 ";
                string   f   =   "文件名 ";
                Response.AppendHeader( "Content-Disposition ",   "attachment;filename= "   +   System.Web.HttpUtility.UrlEncode(f,   System.Text.Encoding.Default)   +   ".xls ");
                Response.ContentEncoding   =   System.Text.Encoding.UTF7;
                Response.ContentType   =   "application/ms-excel ";       //设置输出文件类型为excel文件。  
                System.IO.StringWriter   oStringWriter   =   new   System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter   oHtmlTextWriter   =   new   System.Web.UI.HtmlTextWriter(oStringWriter);
                this.gvcftjb.RenderControl(oHtmlTextWriter);
                Response.Output.Write(oStringWriter.ToString());
                Response.Flush();
                Response.End();

------解决方案--------------------
Response.Charset = "gb2312 ";

------解决方案--------------------
Response.ContentEncoding = System.Text.Encoding.GetEncoding( "utf-8 ");
看看行不行??
------解决方案--------------------
Response.AppendHeader( "Content-Disposition ", "attachment;filename= " + System.Web.HttpUtility.UrlEncode(f+ ".xls "), System.Text.Encoding.Default));
试一下这个
------解决方案--------------------
相同的问题我也碰到过,在等答案