3
Answers

Export dataSet to Excel

Photo of krolick

krolick

20y
2.9k
1
Hello everyone, This is the first time I am posting to this forum. I have read and read all I can find for exporting the dataset I have to Excel. I still can not do it. All I am looking for is a simple explanation on how to do this. Can anyone help me? I am using C#.NET in a Windows Application. I have the dataSet displaying in the app on a datagrid and that works fine. I have it exporting to an XML file right now and can read that in Excel after some conversions. I just need to make it user friendly Just need to export it in excel format. Thanks in advance for your help. Chuck

Answers (3)

0
Photo of hans.henrik
NA 2 0 20y
If you don't have Excel installed you could use following freware library to write Excel files: http://www.carlosag.net/Tools/ExcelXmlWriter/Default.aspx I'm using this library and it is easy to use. I think you have Excel installed so try to look at this example : http://www.c-sharpcorner.com/Code/2004/June/AccessExcelDb.asp buller
0
Photo of krolick
NA 16 0 20y
I already have a connection and can read the dataset in a datagrid on my App....I just need to export it to Excel.... Thanks Chuck
0
Photo of S_Kiryazov
NA 145 0 20y
Here is what I posted in another thread: The first and more "civilised" one is with ODBC data source through OleDB. I have never tried this but it should work. Do the following: Run "Data sources (ODBC)" from Administrative tools. Go to tab "System DSN" Click add, then choose Microsoft Excel driver. Type the name of the data source, say "Excel test". Click finish and then Select workbook. This normally is enough but you've got to build the ConnectionString by hand. Here is a workaround. Create a new text file, change it's extension to .udl and click properties. You get the datalink properties. Go to Connection tab and from the "Use data source name" combo choose your newly created data source. It must be there. That's all, click OK and open the .udl file with a text editor and you've got the connection string. Mine is "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Excel test" Now create the OleDbConnection object and bla bla bla