zoukankan      html  css  js  c++  java
  • GridView导出 Excel文件内容出现乱码

     Response.Charset = "GB2312";
                Response.Charset = "";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                Response.AppendHeader("Content-Disposition""attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8) + ".xls\"");
                Response.ContentType = "application/ms-excel";
                Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">");

                System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
                xPanel.RenderControl(oHtmlTextWriter);
                Response.Write(oStringWriter.ToString());
                Response.End();

    //以下不加也没报错,有的说要加上

    public override void VerifyRenderingInServerForm(Control control)
        {
            //base.VerifyRenderingInServerForm(control);
        }

  • 相关阅读:
    第五篇
    第四篇
    PAT Basic 1094 谷歌的招聘 (20 分)
    PAT Basic 1093 字符串A+B (20 分)
    Dubbo 04 服务化最佳实现流程
    Dubbo 03 Restful风格的API
    Dubbo 02 微信开发
    Dubble 01 架构模型&start project
    PAT Basic 1020 月饼 (25 分)
    PAT Basic 1019 数字黑洞 (20 分)
  • 原文地址:https://www.cnblogs.com/sunheyubo/p/2377487.html
Copyright © 2011-2022 走看看