[dba-VB] Exporting Data to an Excel Spreadsheet

Doug Murphy dw-murphy at cox.net
Tue Sep 27 16:44:14 CDT 2011


You can save a datatable as xml which Excel can open.

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan
Sent: Tuesday, September 27, 2011 12:41 PM
To: df.waters at comcast.net; Discussion concerning Visual Basic and related
programming issues.
Subject: Re: [dba-VB] Exporting Data to an Excel Spreadsheet

Honestly, programmers these days!  If there's no "built in method",  they're
lost.  That's what .Net does for your :-)
 
Grab some data ( any data)
Open a file for Output
Step through your data, building a comma separated list for each record and
write it to the a file.

If you want to write the data into an actual Excel file, use COM.  Again,
step through your data writing values out to the file,  You could base it on
something like
http://vb.net-informations.com/excel-2007/vb.net_excel_2007_create_file.htm

--
Stuart

On 27 Sep 2011 at 10:26, Dan Waters wrote:

> I have unfortunately discovered that there is no built-in method to 
> create a spreadsheet from within VB.Net, similar to 
> DoCmd.TransferSpreadsheet like there is in Access.
> 
> I've tried three different methods, but all have failed for one reason 
> or another.  There are numerous 3rd party solutions, but right now I 
> just need to do the basic step of creating a csv or xls file.
> 
> I'm starting with a Linq query (an IEnumerable).  I'd like to use this 
> as the starting point, but I could convert that to a DataTable, or to 
> a DataSet if needed.
> 
> If anyone does this successfully, please let me know.
> 
> Thanks!
> Dan
> 
> 
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
> 
> 



_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com




More information about the dba-VB mailing list