ASP.NET - how to write data to an excel file - Asked By Sameer Khan on 10-Aug-12 07:41 AM

hi,
i have googled a bit to find a solution that shows me how to write the data to an excel file.
But mostly what i have found is there are external dll or tools to do so.
My application is in Asp.net mvc3 coded in C#.Net . I dont want to use the external dll's in my application. Is there any other method or logic to write the data into an excel.
Please suggest.
Thanks.
Hemanth Kumar replied to Sameer Khan on 10-Aug-12 07:43 AM
Sameer Khan ,

You have to refer to the follwing links for Excel File Dumping

http://www.codeproject.com/Articles/19509/Write-Data-to-Excel-using-C

http://forums.asp.net/t/1643035.aspx/1

Jitendra Faye replied to Sameer Khan on 10-Aug-12 07:58 AM
.Net doesn't provide any predefined classes of method to write data to excel file,

for this you can show data in grid and you can export that data.

follow this article here you will get example-


http://www.eggheadcafe.com/tutorials/asp-net/1eb642e7-23c3-4e83-b6e1-e6b5eb0a6367/aspnet--export-gridview-to-excel.aspx
messy leon replied to Sameer Khan on 11-Aug-12 01:50 AM
To write in excel file ..

DataTable.Value("column name","sheet name") = result

To export the datatable...

DataTable.Export "file path"
For more information read it http://www.dapfor.com/en/net-suite/net-grid/tutorial/data-sorting