Solved

Dataset to Excel

Posted on 2013-05-14
4
379 Views
Last Modified: 2013-05-15
I want to write an Excel file with a dataset . How can this be done?
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:JHalliday
ID: 39165654
I'm making some assumptions here as your question is a little vague but I'm assuming you have knowledge of Visual Basic and understand the concept of "for each" looping.

The easiest way to do what you need is to write the data set to a CSV file that can be opened in Excel. Therefore you will need to do the following (this is in pseudo code)

Create dataset
Declare an empty string called strOutput
Open a new empty file four output and put it in Append mode

For each row in dataset

   For each column in the row
      Read each field and add to a strOutput + ","
   Loop each column

   Write strOutput to the output file[/indent]
Loop each row

close the file
empty the dataset

Open in new window

Hope this makes sense

Regards

Jon
0
 

Author Comment

by:VBdotnet2005
ID: 39165731
I found this object. It works pretty good. I have datatable and I want to save it to Excel file. Now, I want to get rid of header name. It displays "column1, column2, etc".
http://closedxml.codeplex.com/
0
 
LVL 5

Accepted Solution

by:
JHalliday earned 500 total points
ID: 39165774
Set the name property of each of your data table columns to what you want otherwise there isn't a way to do this as your treating the data as a DataTable in Excel and you have to have column names in the Excel DataTable.

If you save it as a CSV it can still be opened in Excel and doesn't require column names.
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question