zoukankan      html  css  js  c++  java
  • 实现将Web页面的内容,Export To Excel的功能

    public void ToExcel(System.Web.UI.Control ctl, string FileName)
        
    {
            HttpContext.Current.Response.Charset 
    = "UTF-8"// 或UTF-7 以防乱码
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
            HttpContext.Current.Response.ContentType 
    = "application/ms-excel";
            HttpContext.Current.Response.AppendHeader(
    "Content-Disposition""attachment;filename=" + "" + FileName + ".xls");
            ctl.Page.EnableViewState 
    = false;
            System.IO.StringWriter tw 
    = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter hw 
    = new System.Web.UI.HtmlTextWriter(tw);
            ctl.RenderControl(hw);
            HttpContext.Current.Response.Write(tw.ToString());
            HttpContext.Current.Response.End();
            ctl.Page.EnableViewState 
    = true;
        }


    原文: http://free56.cn/post/4.html 
  • 相关阅读:
    html5——渐变
    html5——背景
    html5——边框
    html5——私有前缀
    html5——盒子模式
    html5——文本阴影
    html5——颜色
    html5——css选择器
    html5——DOM扩展
    html5——多媒体(一)
  • 原文地址:https://www.cnblogs.com/skywind/p/470699.html
Copyright © 2011-2022 走看看