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();
            }

  • 相关阅读:
    nsstring -->nsdictionary
    卫辉市,
    iPhone 手机内存,
    连接错误,等的好漫长,
    BZOJ 1631==USACO 2007== POJ 3268 Cow Party奶牛派对
    POJ 2837 Til the Cows Come Home
    POJ 1285 确定比赛名次
    Codevs 2833 奇怪的梦境
    Codevs 1063 合并果子
    Codevs 1231 最优布线问题
  • 原文地址:https://www.cnblogs.com/windstore/p/1584071.html
Copyright © 2011-2022 走看看