• 。Net 导出excel Demo


    protected void Button1_Click(object sender, EventArgs e)
            {
                Response.Clear();
                Response.Buffer = true;
                Response.AddHeader("content-disposition", "attachment; filename=YCJQ_Excel_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
                Response.ContentType = "application/vnd.ms-excel";
                //Response.ContentType = "application/vnd.ms-word";
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.Charset = "";
                this.EnableViewState = false;
                StringWriter oStringWriter = new StringWriter();
                HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);

                DataGrid dg = new DataGrid();
                dg.DataSource = bll.GetList(""); //  数据源!!!!!!
                dg.DataBind();

                dg.RenderControl(oHtmlTextWriter);
                Response.Write(oStringWriter.ToString());
                Response.End();

                ////导出整个页面到Excel/Word
                Response.Clear();
                Response.Buffer = true;
                Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMMdd") + ".doc");
                Response.ContentEncoding = System.Text.Encoding.UTF7;
                //Response.ContentType = "application/vnd.ms-excel";
                ////Response.ContentType = "application/vnd.ms-word";
                //Response.ContentType = "application/word";
                this.EnableViewState = false;
            }

  • 相关阅读:
    024.Zabbix告警等级机制
    023.Zabbix自定义(邮箱)脚本告警-02
    022.Zabbix自定义(邮箱)脚本告警01
    021.Zabbix的邮件告警-01
    020.Zabbix的Actions配置
    019.Zabbix的Trigger及相关函数
    018.Zabbix维护时间和模板导入
    017.Zabbix宏介绍
    016.Zabbix聚合监控
    015.Zabbix的日志监控配置
  • 原文地址:https://www.cnblogs.com/Zhuangsd/p/5655369.html
Copyright © 2020-2023  润新知