Import/Export E worksheet using ADO.Net
Excel is very known format for storing small amount of data. So you may want your data residing in ms sql or oracle or any other data source do be exported because of any of the following reason:
- Running calculation to derive the wanted information
- Doing some statistical computation like MEAN, MEDIAN, MODE
- Generating Graphical report
- Making use of PivotTable and PivotChart
Apart from above listed one there exists also lots of other reasons to export data in excel format. Similarily we can use excel to do bulk import of data and put it into sql server database. It is very easy and faster to do data entry in excel sheet and then import those data to rdbms system.
Export to Excel from SQL Server:
There are may ways we can read data from sql server and export to excel sheet like using third party controls, binding data to some data controls and then exporting using "GridView.RenderControl()" method.
But here I am going to show how to export from sql server to ms excel using ado.net.
1. Create an asp.net website project named "ExcelExportImport" and 2 folders to it "DownloadFiles" and "UploadFiles".
2. Download AdventureWorksLT2008 database and attach ot your sql server database. More...