将gridview导出为Excel工作表 [英] Exporting gridview to excel sheet

查看:80
本文介绍了将gridview导出为Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.IO.StringWriter sw = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);

        // Render grid view control.
        reportGrid.RenderControl(htw);

        // Write the rendered content to a file.
        string renderedGridView = sw.ToString();
        File.WriteAllText(Request.MapPath("~/Account/temp.xls"), renderedGridView);
        htw = new System.Web.UI.HtmlTextWriter(sw);





我使用了这个并获得了数据导出

但删除和编辑按钮仍然显示在Excel工作表中

并且只添加了一个页面...



I used this and got data exported
But delete and edit buttons are still getting displayed in excel sheet
And only one page is getting added...

推荐答案

你可以查看这篇文章 -

这里使用了复选框,但导出的excel表中没有显示复选框 -

http://www.aspdotnet-suresh.com /2011/12/export-selected-gridview-rows-to-excel.html [ ^ ]
You Can Check this Article-
Here checkboxes is used but checkboxes are not showing in exported excel sheet-
http://www.aspdotnet-suresh.com/2011/12/export-selected-gridview-rows-to-excel.html[^]


Preapare Gridview首先导出为

http://www.c-sharpcorner.com/UploadFile/DipalChoksi/exportxl_asp2_dc11032006003657AM/exportxl_asp2_dc.aspx [ ^ ]
Preapare Gridview for export first as
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/exportxl_asp2_dc11032006003657AM/exportxl_asp2_dc.aspx[^]


这篇关于将gridview导出为Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆