Hi,
I want to export the datagrid into the excel file.
Please give me the solution as soon as possible.
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raj KumarPosted Aug 12, 2008, 1:01 AM
See these articles:
Export to Excel is one of the most common functionality required in ASP.NET pages. Users can download the data from the DataGrid into an Excel spreadsheet for offline verification and/or computation.
This article describes how to Export an ASP.Net 2.0 GridView to Excel.
In this version of the article, we will include the handling the Hyperlink columns in the GridView export to Excel and also re-factor our original logic to use more general features of Reflection.
Niradhip ChakrabortyPosted Aug 7, 2008, 5:48 PM
Hi Kamal welcome to c-sharpcorner.
You can check out the article by Dipal Choksi in c-sharpcorner
1.http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ExportASPNetDataGridToExcel11222005041447AM/ExportASPNetDataGridToExcel.aspx
or you also can refer the following articles:
1.http://www.codersource.net/published/view/283/exporting_data_grid_to_excel.aspx
2.http://www.codeproject.com/KB/cs/export2excel.aspx
Blocked AccountPosted Aug 7, 2008, 5:22 AM
For exporting the datagrid into the excel use this code:
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
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);
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
Happy Coding!!