ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DataSet to Excel/text (https://www.excelbanter.com/excel-programming/324398-dataset-excel-text.html)

11Oppidan

DataSet to Excel/text
 
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.




Tom Ogilvy

DataSet to Excel/text
 
Activeworkbook.SaveAs Filename:="ABCD.csv", FileFormat:=xlCSV

would be the way to write it in VBA. Assume it would be similar in .NET.

--
Regards,
Tom Ogilvy

"11Oppidan" wrote in message
...
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.






shriop

DataSet to Excel/text
 
"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.


Peter Huang [MSFT]

DataSet to Excel/text
 
Hi

You also take a look at the link below.
HOW TO: Transfer Data to an Excel Workbook by Using Visual Basic .NET
http://support.microsoft.com/?id=306022

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.



All times are GMT +1. The time now is 12:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com