码迷,mamicode.com
首页 > 其他好文 > 详细

GridView 导出Excel

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

标签:style   color   os   io   数据   for   ar   代码   

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

标签:style   color   os   io   数据   for   ar   代码   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!