zoukankan      html  css  js  c++  java
  • GridView 导出Excel

    protected void btndaochu_Click(object sender, EventArgs e)
            {
                GetList();//读取GridView 数据  这里就不写了
                Response.Clear();
                Response.Charset = "utf-8";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                Response.Buffer = true;
                Response.AppendHeader("Content-Disposition", "attachment;filename=中标数据集合.xls");
                Response.ContentType = "application/ms-excel";
                this.EnableViewState = false;
                System.IO.StringWriter tw = new System.IO.StringWriter();
                HtmlTextWriter hw = new HtmlTextWriter(tw);
                this.GridViewMain.RenderControl(hw);
                Response.Output.Write(tw.ToString());
                Response.Flush();
                Response.End();
            }
            public override void VerifyRenderingInServerForm(Control control)
            {
                //无须填写任何代码
            }

  • 相关阅读:
    Ubuntu
    VSCode
    VSCode
    Astyle
    Qt
    待办
    Qt
    Qt
    Qt
    python pip常用命令、配置pip源
  • 原文地址:https://www.cnblogs.com/sl372/p/3921566.html
Copyright © 2011-2022 走看看