zoukankan      html  css  js  c++  java
  • 将ASP.NET 数据导出到execl

    图片 将上图数据保存到execl

    //导出到execl
            protected void Execl_Click(object sender, EventArgs e)
            {
                System.Web.UI.Control ctl = this.Repeater1;
                //Repeater1是你在窗体中拖放的控件
     
                HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=Excel.xls");
                HttpContext.Current.Response.Charset = "UTF-8";
     
                HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
                HttpContext.Current.Response.ContentType = "application/ms-excel";
     
                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(); 
     

            }  图片 

     
     
  • 相关阅读:
    各种 SDk
    面试第一周
    KVC/KVO 的概述和使用
    How Many Tables HDU
    The Suspects POJ
    Wireless Network POJ
    Layout POJ
    The Shortest Path in Nya Graph HDU
    Extended Traffic LightOJ
    Tram POJ
  • 原文地址:https://www.cnblogs.com/jiangyongyawen/p/4241343.html
Copyright © 2011-2022 走看看