zoukankan      html  css  js  c++  java
  • 导出EXECL 2003正常 2007 不正常问题

     Response.ClearContent();               

      Response.Buffer = true;              

       Response.Charset = "utf-8";               

      Response.AppendHeader("Content-Disposition", "attachment; filename=EnergyReport" +                     DateTime.Now.ToString("_yyyyMMdd_HHmmss") + ".xls");                

    Response.ContentEncoding = System.Text.Encoding.Default;            

         Response.ContentType = "application/ms-excel";

                    gv.AllowPaging = false;           

          gv.DataBind();              

       this.EnableViewState = false;             

        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("ZH-CN", true);

                    System.IO.StringWriter tw = new System.IO.StringWriter(ci);          

           HtmlTextWriter hw = new HtmlTextWriter(tw);       

              gv.RenderControl(hw);

                    Response.Output.Write(tw.ToString());

                    gv.AllowPaging = true;              

       gv.DataBind();

                    Response.Flush();             

        Response.End();

    红色是主要的!

  • 相关阅读:
    数组
    Spring创建对象的三种方式以及创建时间
    Struts文件上传下载
    自定义拦截器
    Struts过滤器
    mybatis整合ehcache
    mybatis主键返回
    shell脚本 列出所有网卡的ip地址
    Servlet执行过程
    centos时区
  • 原文地址:https://www.cnblogs.com/DotNetCSharp/p/2299142.html
Copyright © 2011-2022 走看看