gridview excel 报表乱码问题

        Response.Charset ="gb2312";
        Response.Buffer
=true;
        Response.AddHeader(
"content-disposition", "attachment;filename="+ HttpUtility.UrlEncode("用户信息表.xls").ToString());
        Response.ContentType
="application/ms-excel";
        Response.Write(
"<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
        System.IO.StringWriter sw
=new System.IO.StringWriter();
        HtmlTextWriter hw
=new HtmlTextWriter(sw);
       
this.GridView1.RenderControl(hw);
        Response.Write(sw.ToString());
        Response.Write(
"</body></html>");
        Response.Flush();
        Response.End();

像这样写问题就解决了。

posted @ 2011-12-20 17:48  猎鹰-aspnet  阅读(184)  评论(0编辑  收藏  举报