Home All Groups Group Topic Archive Search About

Export from VB.NET 2003 to an Excel spreadsheet

Author
12 Jan 2006 6:10 PM
Scott M. Lyon
I'm trying to figure out a way to export data (actually the result of a
Stored Procedure call from SQL Server) into a specified Excel spreadsheet
format.


Currently, I have the data read into a DataSet that consists of one
DataTable.

That DataTable has a specific name (for arguments purposes, let's say it's
called "DataGrid"), that I need to use as the tab name in the exported Excel
spreadsheet.

That DataTable has specific column names, which I want to use as the first
row on that worksheet (of the exported Excel). I then want to use the
remaining rows to populate the rest of the cells in the spreadsheet.


Is there an easy way to do this?


I am currently using an OleDBAdapter object to read from an Excel
spreadsheet (something that would also apply to this newly-exported Excel
spreadsheet), and using it's Filll method to populate a DataSet.


Is there an easy way to do it the other way, going from a DataSet (or
DataTable) to an Excel spreadsheet?


Thanks!

-Scott

Author
12 Jan 2006 6:29 PM
S Shulman
I don't know of any built in function that creates excel but ther one for
XML I just create CSV file (don't forget about the commas) or you may open
Excel document using office automation and populate the document
I can send you some sample code

hth,
Shmuel Shulman

Show quoteHide quote
"Scott M. Lyon" <scott.RED.lyon.WH***@rapistan.BLUE.com> wrote in message
news:%23v5VFO6FGHA.2064@TK2MSFTNGP09.phx.gbl...
> I'm trying to figure out a way to export data (actually the result of a
> Stored Procedure call from SQL Server) into a specified Excel spreadsheet
> format.
>
>
> Currently, I have the data read into a DataSet that consists of one
> DataTable.
>
> That DataTable has a specific name (for arguments purposes, let's say it's
> called "DataGrid"), that I need to use as the tab name in the exported
> Excel spreadsheet.
>
> That DataTable has specific column names, which I want to use as the first
> row on that worksheet (of the exported Excel). I then want to use the
> remaining rows to populate the rest of the cells in the spreadsheet.
>
>
> Is there an easy way to do this?
>
>
> I am currently using an OleDBAdapter object to read from an Excel
> spreadsheet (something that would also apply to this newly-exported Excel
> spreadsheet), and using it's Filll method to populate a DataSet.
>
>
> Is there an easy way to do it the other way, going from a DataSet (or
> DataTable) to an Excel spreadsheet?
>
>
> Thanks!
>
> -Scott
>
Author
12 Jan 2006 7:59 PM
JFB
Check this out
http://www.vbdotnetheaven.com/Code/Jul2003/2124.asp
Rgds
JFB

Show quoteHide quote
"S Shulman" <smshul***@hotmail.com> wrote in message
news:O0f1QY6FGHA.648@TK2MSFTNGP14.phx.gbl...
>I don't know of any built in function that creates excel but ther one for
>XML I just create CSV file (don't forget about the commas) or you may open
>Excel document using office automation and populate the document
> I can send you some sample code
>
> hth,
> Shmuel Shulman
>
> "Scott M. Lyon" <scott.RED.lyon.WH***@rapistan.BLUE.com> wrote in message
> news:%23v5VFO6FGHA.2064@TK2MSFTNGP09.phx.gbl...
>> I'm trying to figure out a way to export data (actually the result of a
>> Stored Procedure call from SQL Server) into a specified Excel spreadsheet
>> format.
>>
>>
>> Currently, I have the data read into a DataSet that consists of one
>> DataTable.
>>
>> That DataTable has a specific name (for arguments purposes, let's say
>> it's called "DataGrid"), that I need to use as the tab name in the
>> exported Excel spreadsheet.
>>
>> That DataTable has specific column names, which I want to use as the
>> first row on that worksheet (of the exported Excel). I then want to use
>> the remaining rows to populate the rest of the cells in the spreadsheet.
>>
>>
>> Is there an easy way to do this?
>>
>>
>> I am currently using an OleDBAdapter object to read from an Excel
>> spreadsheet (something that would also apply to this newly-exported Excel
>> spreadsheet), and using it's Filll method to populate a DataSet.
>>
>>
>> Is there an easy way to do it the other way, going from a DataSet (or
>> DataTable) to an Excel spreadsheet?
>>
>>
>> Thanks!
>>
>> -Scott
>>
>
>
Author
12 Jan 2006 8:01 PM
JFB
Maybe this is better for you!
http://www.codeproject.com/vb/net/Data_Extract.asp
JFB

Show quoteHide quote
"S Shulman" <smshul***@hotmail.com> wrote in message
news:O0f1QY6FGHA.648@TK2MSFTNGP14.phx.gbl...
>I don't know of any built in function that creates excel but ther one for
>XML I just create CSV file (don't forget about the commas) or you may open
>Excel document using office automation and populate the document
> I can send you some sample code
>
> hth,
> Shmuel Shulman
>
> "Scott M. Lyon" <scott.RED.lyon.WH***@rapistan.BLUE.com> wrote in message
> news:%23v5VFO6FGHA.2064@TK2MSFTNGP09.phx.gbl...
>> I'm trying to figure out a way to export data (actually the result of a
>> Stored Procedure call from SQL Server) into a specified Excel spreadsheet
>> format.
>>
>>
>> Currently, I have the data read into a DataSet that consists of one
>> DataTable.
>>
>> That DataTable has a specific name (for arguments purposes, let's say
>> it's called "DataGrid"), that I need to use as the tab name in the
>> exported Excel spreadsheet.
>>
>> That DataTable has specific column names, which I want to use as the
>> first row on that worksheet (of the exported Excel). I then want to use
>> the remaining rows to populate the rest of the cells in the spreadsheet.
>>
>>
>> Is there an easy way to do this?
>>
>>
>> I am currently using an OleDBAdapter object to read from an Excel
>> spreadsheet (something that would also apply to this newly-exported Excel
>> spreadsheet), and using it's Filll method to populate a DataSet.
>>
>>
>> Is there an easy way to do it the other way, going from a DataSet (or
>> DataTable) to an Excel spreadsheet?
>>
>>
>> Thanks!
>>
>> -Scott
>>
>
>