zoukankan      html  css  js  c++  java
  • 将Gridview导出到Excel

    GridViewToExcel(EdceExcelGV, "application/ms-exce","xxxxxx表");

    protected void GridViewToExcel(Control ctrl, string FileType, string FileName)
    {

    /*Response.Charset = "GB2312";
    Response.ContentEncoding = Encoding.UTF8;
    HttpContext.Current.Response.AppendHeader("Content-Disposition",
    "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
    HttpContext.Current.Response.ContentType = FileType;//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
    this.EnableViewState=false;
    StringWriter sw=new StringWriter ();
    HtmlTextWriter htw=new HtmlTextWriter(sw);
    ctrl.RenderControl(htw);
    HttpContext.Current.Response.Write(sw.ToString());
    HttpContext.Current.Response.End();*/

    Response.ClearContent();
    Response.BufferOutput = true;
    Response.Charset = "utf-8";
    Response.ContentType = FileType;
    Response.ContentEncoding = System.Text.Encoding.UTF8;
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(FileName) + ".xls");
    this.EnableViewState=false;
    StringWriter sw=new StringWriter ();
    HtmlTextWriter htw=new HtmlTextWriter(sw);
    ctrl.RenderControl(htw);
    HttpContext.Current.Response.Write(sw.ToString());
    HttpContext.Current.Response.End();
    }
    public override void VerifyRenderingInServerForm(Control control)
    {
    }

  • 相关阅读:
    CodeForces
    CodeForces-1253B(贪心+模拟)
    WebFlux、Reactive编程特性
    redis-on-windows配置解释
    SpringBoot配置方式补充
    如何在 Ubuntu 20.04 上安装 Python Pip
    MySQL之1055错误
    CuckooSandbox
    Manjaro 20.0.1 Lysia 安装Googlepinyin
    Manjaro 20.0.1 Lysia 更新国内镜像源
  • 原文地址:https://www.cnblogs.com/jinhaoObject/p/4496416.html
Copyright © 2011-2022 走看看