DataSet to Excel/text

  • Thread starter Thread starter 11Oppidan
  • Start date Start date
1

11Oppidan

Hi,

Please could someone help me do the following in VB .NET. I would like to
know the most efficient way to write a populated dataset to a csv or text
file, naming and labelling the file and sheet. Is one able to use
dataset.writeXML(path). I can get this to work but I would like it in
normal excel format rather then xml code.

Any examples would be much appreciated.
 
Activeworkbook.SaveAs Filename:="ABCD.csv", FileFormat:=xlCSV

would be the way to write it in VBA. Assume it would be similar in .NET.
 
"most efficient way" is a loaded phrase, and you wouldn't write an
entire dataset to a csv file, you'd have to just write a DataTable's
worth. You also wouldn't be able to specify sheet name, because that's
specific to xls and not csv. Csv can basically only hold one flat
tables worth of data. I do have a component that will handle this for
you, which I'm sorry to say is not free, if that's a requirement. It is
however only one line other than creating the component and disposing
the component. I also have a benchmarks page that compares "efficiency"
of my component vs the jet driver and the microsoft text driver. The
method to look for is CsvWriter.WriteAll. It's in the help docs, and
used in the Tab Delimited to CSV sample. There's also a demo version
available for download to see how it works.

http://www.geocities.com/shriop/index.html is the main page. There's a
samples link, benchmarks link, help docs link, and demo version link
all off of that page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top