Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi
I have a data base in access file and want to export this data to excel sheet using C#.
Posted 13-Jan-13 1:35am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You have got 2 ways:
1) field by field - cell by cell, as is described here: http://stackoverflow.com/questions/4772272/exporting-data-to-excel-file-c-net[^]
2) using recordset and Excel method: CopyFromRecordset (prefered)
Steps to do:
a) connect to the database:
http://www.c-sharpcorner.com/UploadFile/9a81a4/adodb-connection-in-net-application-using-C-Sharp/[^]
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!
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 279
1 OriginalGriff 190
2 DamithSL 185
3 Peter Leow 105
4 Kornfeld Eliyahu Peter 105
0 OriginalGriff 7,355
1 DamithSL 5,254
2 Sergey Alexandrovich Kryukov 4,942
3 Maciej Los 4,906
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100