首页 > Web开发 > 详细

将ASP.NET 数据导出到execl

时间:2015-01-22 14:45:32      阅读:295      评论:0      收藏:0      [点我收藏+]

技术分享 将上图数据保存到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(); 
 

        }  技术分享 

 
 

将ASP.NET 数据导出到execl

原文:http://www.cnblogs.com/jiangyongyawen/p/4241343.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!