Click here to Skip to main content
14,734,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have a data base in access file and want to export this data to excel sheet using C#.

If you use Access, one quite easy way is to use TransferText[^] method to save the data in a CSV file and then open it using Excel. You can use for example Interop for Access to call appropriate methods.

Another way could be to use OleDb and open a connection with OleDbConnection and do a select to appropriate table and save the result in a dataset. After that, export the dataset to Excel. There are lots of articles concerning this, for example:
- Fast Exporting from DataSet to Excel[^]
- DataTable to Excel[^]
- Export to EXCEL from Datatable in C#.Net[^] etc.
You have got 2 ways:
1) field by field - cell by cell, as is described here:[^]
2) using recordset and Excel method: CopyFromRecordset (prefered)
Steps to do:
a) connect to the database:[^]
b) fill the ADODB.Recordset object
c) create an instance of MS Excel
d) copy data from recordset in to excel sheet using CopyFromRecordset[^] method.

Good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900