zoukankan      html  css  js  c++  java
  • c# 导出为Excel 的例子

    #region 导出excel
        /// <summary>
        /// yinmin 导出panel控件中的内容到excel
        /// </summary>
        /// <param name="plOut"></param>
        public static void OutPutExcel(Panel plOut)
        {
            System.Web.HttpContext.Current.Response.Clear();
            System.Web.HttpContext.Current.Response.Buffer = true;
            System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=File.xls");
            System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";

            //this.EnableViewState = false;
            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

            plOut.RenderControl(oHtmlTextWriter);
            System.Web.HttpContext.Current.Response.Write(oStringWriter.ToString());
            System.Web.HttpContext.Current.Response.End();

        }

        #endregion

  • 相关阅读:
    字符链接
    成绩统计
    看不懂的代码
    新的开始
    appserv 求指教php运行环境
    指针 数组 复制
    HTML 标题居中 小小积累
    用指针 数组连接
    [导入]Hibernate+Spring+Struts2+ExtJS开发CRUD功能
    [导入]Hibernate+Spring+Struts2+ExtJS开发CRUD功能
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1763550.html
Copyright © 2011-2022 走看看