Solved

Dataset to Excel

Posted on 2013-05-14
4
374 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
  • 2
4 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 
LVL 5

Expert Comment

by:JHalliday
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows Service with UDP 2 26
Crystal Report for VS2013 17 36
Hide Tab Page 3 18
fomat Json objects 6 15
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now