zoukankan      html  css  js  c++  java
  • 输出datagrid的内容到excel

    private void OutPutToExcel()
            {
                Response.Clear();
                Response.Buffer = true;

                Response.Charset = "GB2312";
                Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">");
                this.EnableViewState = false;
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                Response.ContentType = "application/ms-excel";
                Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("FileName", System.Text.Encoding.UTF8) + ".xls");
                System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
                StringWriter sw = new StringWriter(myCItrad);
                HtmlTextWriter writer = new HtmlTextWriter(sw);
                GridExcel.RenderControl(writer);
                Response.Write(sw.ToString());
                Response.End();
            }

  • 相关阅读:
    日志
    mysql锁
    慢查询
    auto_increment
    脚本
    服务器元数据
    复制表及表数据
    临时表
    (一)校园信息通微信小程序从前端到后台整和笔记
    OpenCart框架运行流程介绍opencart资料链接
  • 原文地址:https://www.cnblogs.com/windstore/p/1584071.html
Copyright © 2011-2022 走看看