首页 > 其他 > 详细

GridView 导出Excel

时间:2014-08-19 12:44:24      阅读:295      评论:0      收藏:0      [点我收藏+]

protected void btndaochu_Click(object sender, EventArgs e)
        {
            GetList();//读取GridView 数据  这里就不写了
            Response.Clear();
            Response.Charset = "utf-8";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            Response.Buffer = true;
            Response.AppendHeader("Content-Disposition", "attachment;filename=中标数据集合.xls");
            Response.ContentType = "application/ms-excel";
            this.EnableViewState = false;
            System.IO.StringWriter tw = new System.IO.StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(tw);
            this.GridViewMain.RenderControl(hw);
            Response.Output.Write(tw.ToString());
            Response.Flush();
            Response.End();
        }
        public override void VerifyRenderingInServerForm(Control control)
        {
            //无须填写任何代码
        }

GridView 导出Excel,布布扣,bubuko.com

GridView 导出Excel

原文:http://www.cnblogs.com/sl372/p/3921566.html

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