日期:2014-05-18  浏览次数:20441 次

gridview导出数据到excel中文乱码的问题 50分!!!
今天在处理gridview导出数据到excel的时候遇到了中文乱码的问题
代码如下:
        protected   void   Button2_Click(object   sender,   EventArgs   e)
        {
                Response.Clear();
                Response.AppendHeader( "Content-Disposition ",   "attachment;filename=\ " "   +   System.Web.HttpUtility.UrlEncode( "table ",   System.Text.Encoding.UTF8)   +   ".xls\ " ");
                Response.ContentEncoding   =   System.Text.Encoding.GetEncoding( "utf-8 ");
                Response.ContentType   =   "application/ms-excel ";
                StringWriter   stringWrite   =   new   StringWriter();
                HtmlTextWriter   htmlWrite   =   new   HtmlTextWriter(stringWrite);
                GridView1.RenderControl(htmlWrite);
                Response.Write(stringWrite.ToString());
                Response.End();
        }
导入到excel后中文出现了乱码
我用的是excel2003请问高手们   怎么解决这个问题啊?

------解决方案--------------------
加上下面两句话看下
System.Globalization.CultureInfo ctinfo = new System.Globalization.CultureInfo( "zh-CN ", true);
Response.Charset = "gb2312 ";