Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to export a dataset to CSV, Excel, etc from Win App

Status
Not open for further replies.

dorianr

Programmer
Mar 26, 2001
32
US
I've been struggling trying to figure out how to write a CSV file and/or an Excel file from a C# dataset in a Windows Form Application. I see plenty of references for Web Apps and Crystal Reports. I see information on reading data into a dataset, but nothing on how to write these files. I was able to export to XML using XMLWriter. Can anyone help me to export my Win App dataset to text (csv) and Excel formats?
Thanks.
 
I've had to write a CSV file from a recordset in ASP, so I don't think it would be that much different to write a CSV file from a win application in .NET. I'm pretty much taking a stab in the dark, but I think you should look at the System.IO.File namespace. You will be able to create and open a file for writing (System.IO.File.Create & System.IO.File.OpenWrite).

From there, you should be able to insert lines of text, like in your CSV file (just make sure you remember to put the commas between your pieces of data).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top