473,508 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export to Excel in VB.NET

I have read numerous articles and postings on various approaches to
exporting
a DataSet to excel while avoiding the use of automation. I found the
most performant approach to be assigning a string array of data to a
range in excel (similar to a copyfromrecordset). However, with this
approach, the datatype is lost and all numeric columns in excel appear
as string.

In order to overcome this, I tried calling TextToColumns on each
column. This works except oddly some string values are getting broken
up into multiple columns.

I have also tried MS code to create a RecordSet from a DataSet and
perform a CopyFromRecordset. The recordset gets created, however the
CopyFromRecordset does not work.

Has anyone had any success with either of these approach...or have
some other approach to export DataSet contents to excel without heavy
use of automation and at the same time maintaining the datatype of the
column?

Thanks in advance.
Nov 20 '05 #1
4 12028
Maybe this can be of some help.

http://www.wizkil-webs.net/NET/DotNE...m#_Toc77487928

B

"John Z." wrote:
I have read numerous articles and postings on various approaches to
exporting
a DataSet to excel while avoiding the use of automation. I found the
most performant approach to be assigning a string array of data to a
range in excel (similar to a copyfromrecordset). However, with this
approach, the datatype is lost and all numeric columns in excel appear
as string.

In order to overcome this, I tried calling TextToColumns on each
column. This works except oddly some string values are getting broken
up into multiple columns.

I have also tried MS code to create a RecordSet from a DataSet and
perform a CopyFromRecordset. The recordset gets created, however the
CopyFromRecordset does not work.

Has anyone had any success with either of these approach...or have
some other approach to export DataSet contents to excel without heavy
use of automation and at the same time maintaining the datatype of the
column?

Thanks in advance.

Nov 20 '05 #2
You can use it directly as a datasource:
http://www.knowdotnet.com/articles/exceldatasource.html

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"John Z." <jo******@yahoo.com> wrote in message
news:da**************************@posting.google.c om...
I have read numerous articles and postings on various approaches to
exporting
a DataSet to excel while avoiding the use of automation. I found the
most performant approach to be assigning a string array of data to a
range in excel (similar to a copyfromrecordset). However, with this
approach, the datatype is lost and all numeric columns in excel appear
as string.

In order to overcome this, I tried calling TextToColumns on each
column. This works except oddly some string values are getting broken
up into multiple columns.

I have also tried MS code to create a RecordSet from a DataSet and
perform a CopyFromRecordset. The recordset gets created, however the
CopyFromRecordset does not work.

Has anyone had any success with either of these approach...or have
some other approach to export DataSet contents to excel without heavy
use of automation and at the same time maintaining the datatype of the
column?

Thanks in advance.

Nov 20 '05 #3
Thanks for your post. I see that you are querying data OUT of Excel
into a DataSet object using ADO.NET, but can the reverse be
accomplished in this manner...can data from a DataSet be pushed INTO
an Excel worksheet?

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message news:<ui**************@TK2MSFTNGP10.phx.gbl>...
You can use it directly as a datasource:
http://www.knowdotnet.com/articles/exceldatasource.html

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"John Z." <jo******@yahoo.com> wrote in message
news:da**************************@posting.google.c om...
I have read numerous articles and postings on various approaches to
exporting
a DataSet to excel while avoiding the use of automation. I found the
most performant approach to be assigning a string array of data to a
range in excel (similar to a copyfromrecordset). However, with this
approach, the datatype is lost and all numeric columns in excel appear
as string.

In order to overcome this, I tried calling TextToColumns on each
column. This works except oddly some string values are getting broken
up into multiple columns.

I have also tried MS code to create a RecordSet from a DataSet and
perform a CopyFromRecordset. The recordset gets created, however the
CopyFromRecordset does not work.

Has anyone had any success with either of these approach...or have
some other approach to export DataSet contents to excel without heavy
use of automation and at the same time maintaining the datatype of the
column?

Thanks in advance.

Nov 20 '05 #4
You could loop through the rows of each table in your dataset seperating
each value with a tab and then each row will be ended with a vbcrlf. Then
save this output to a file with a .xls. You should then be able to open
this up using excel since its in a format that excel can understand.
"John Z." <jo******@yahoo.com> wrote in message
news:da**************************@posting.google.c om...
Thanks for your post. I see that you are querying data OUT of Excel
into a DataSet object using ADO.NET, but can the reverse be
accomplished in this manner...can data from a DataSet be pushed INTO
an Excel worksheet?

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message

news:<ui**************@TK2MSFTNGP10.phx.gbl>...
You can use it directly as a datasource:
http://www.knowdotnet.com/articles/exceldatasource.html

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"John Z." <jo******@yahoo.com> wrote in message
news:da**************************@posting.google.c om...
I have read numerous articles and postings on various approaches to
exporting
a DataSet to excel while avoiding the use of automation. I found the
most performant approach to be assigning a string array of data to a
range in excel (similar to a copyfromrecordset). However, with this
approach, the datatype is lost and all numeric columns in excel appear
as string.

In order to overcome this, I tried calling TextToColumns on each
column. This works except oddly some string values are getting broken
up into multiple columns.

I have also tried MS code to create a RecordSet from a DataSet and
perform a CopyFromRecordset. The recordset gets created, however the
CopyFromRecordset does not work.

Has anyone had any success with either of these approach...or have
some other approach to export DataSet contents to excel without heavy
use of automation and at the same time maintaining the datatype of the
column?

Thanks in advance.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5348
by: congngo | last post by:
Hi all Every time I export a table into an excel spreadsheet. It has a leading apostrophe on every cells. This drive me nut. I have to do a work around by export table into a txt file than...
5
2651
by: Tim Frawley | last post by:
I created a .NET Com Class object for use in ASP reports to export database results directly to Excel. I have it all working just find but I cannot get the Excel process to go away after the job...
3
2579
by: ABC | last post by:
What methods can export excel file from stored procedure with parameters which input from web form?
1
3038
by: panku007 | last post by:
hi All, I wanted to export excel data into ms word document through java coding.So please send me reply,according to my question. thanks
2
1847
by: tbenchakroune | last post by:
How can I export Excel spreadsheets to Access db? Thanks, T.
1
2842
by: san1014 | last post by:
Hi How to import and export excel data into oracle database using java. Thank you
1
6180
by: CF FAN | last post by:
Can Report Builder Export Excel Files with multiple Sheets How can I create a report that it can export in excel by multiple
3
3015
by: minhtran | last post by:
Hi all Anyone has any idea how to get a Excel header column in VB.NET. Please, help me. Thank you so much in advance
0
2498
by: Dubois | last post by:
Bonjour Lorsque je lance un export excel au travert d'une page en ASP.NET C#, cela fonctionne sur la machine de développement, par contre, sur le serveur de production j'ai l'erreur suivante : ...
3
4052
by: prashantdixit | last post by:
Hi, I am trying to export excel data to text file in a particular format. The Format for each ROW of Excel is like IMAN_ROOT/bin/import_file -f=<Column A> -type=<Column B> -d=<Column C>...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.