将GridView导出到Excel文件 [英] export gridview into excel file

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

问题描述



在这里,我正在开发Web应用程序,并且在其中具有gridview,并且excel表具有与gridview相同的列名,并且我想将gridview的内容相对于girdview的字段名称导出到excel表中,请帮助我,朋友,



here i am developing web application and in it i have gridview, and excel sheet having same column names as gridview and i want export the content of gridview into excel sheet with respect to the field name of girdview, please help me out friends,

推荐答案

尝试使用此工具
导出到Excel
Try this tool
Export To Excel


养成通过google firsr进行冲浪的习惯,请参考以下内容,它可能会帮助您:''
如何将GridView导出到Excel,渲染单元格,添加艺术字并填充自定义模板 [ ^ ]

http://www.aspdotnet-suresh. com/2011/04/how-to-export-gridview-data-to-excel-or.html [ http://www.c-sharpcorner. com/UploadFile/DipalChoksi/exportxl_asp2_dc.aspx?ArticleID = 000c64fb-8a22-414a-8247-984335aaa0eb [ http://shawpnendu.blogspot.com/2009/03/export- gridview-data-to-excelword-text.html [ ^ ]
make habit of surf through the google firsr , Let it be reffer the following , it might help you:''
How to export GridView to Excel, render cells, add WordArt, and fill a custom template[^]

http://www.aspdotnet-suresh.com/2011/04/how-to-export-gridview-data-to-excel-or.html[^]
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/exportxl_asp2_dc11032006003657AM/exportxl_asp2_dc.aspx?ArticleID=000c64fb-8a22-414a-8247-984335aaa0eb[^]
http://shawpnendu.blogspot.com/2009/03/export-gridview-data-to-excelword-text.html[^]


您应该在exceldownload按钮点击事件上使用此方法
You should be use this method on your exceldownload button click event
 public void excelgridview()

{

        Response.Clear();

        Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");

        Response.Charset = "";

        // If you want the option to open the Excel file without saving than

        // comment out the line below

        // Response.Cache.SetCacheability(HttpCacheability.NoCache);

        Response.ContentType = "application/vnd.xls";

        System.IO.StringWriter stringWrite = new System.IO.StringWriter();

        System.Web.UI.HtmlTextWriter htmlWrite =
        new HtmlTextWriter(stringWrite);

        GridView1.RenderControl(htmlWrite);

        Response.Write(stringWrite.ToString());

        Response.End();

    }

    public override void VerifyRenderingInServerForm(System.Web.UI.Control control)
    {

        // Confirms that an HtmlForm control is rendered for the
        //  specified ASP.NET server control at run time.

    }


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

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