Display gridview result in an excel

Posted by Bhadri under C# on 1/9/2013 | Points: 10 | Views : 1811 | Status : [Member] | Replies : 1
In my code behind , I have converted the datatable into a list of Entities to display in the view. I am binding this list to my gridview. I am able to get the data in the grid view.
Now, I want to view this data in an excel instead of a grid view i.e. my result should appear in excel instead of displaying in the gridview.
It is not an export to Excel. I want my result to be populated in the excel sheet instead of getting displayed in the gridview.
Please help me to achieve this.
Thanks!!!




Responses

Posted by: Nisar87 on: 1/18/2013 [Member] Starter | Points: 25

Up
0
Down
Why are you thinking differently while displaying records in excel. Just create a gridview at runtime and assign the datatable to that grid. Now grid is populated but will not show to the users because grid is not added any control.
Now simply export that grid to excel. and you will achieve what you are looking for.
I hope you get my point.
[code]
GridView Grd = Fill_Grid_Func();
GridViewExportUtil.Export("Customers.xls", Grd);
Grd = null;
[/code]

for Export please refer following link
http://www.dotnetobject.com/Thread-Export-GridView-to-Excel-Asp-net

_______________________________________
Nisar Ahmad
http://www.dotnetobject.com/

Bhadri, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response