469,328 Members | 1,324 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

How to Create Excel File(.xls) from VB.Net App

Hi All,

Can anyone tell me how to create an Excel (.xls) file from a VB.Net app? I
have a SQL Server database that contains a table with the data I want to
export. How do I create the file? Any code samples?

Thanks for your help!
Jul 21 '05 #1
2 12296

Hi..

http://www.vbdotnetheaven.com/Code/Jul2003/2124.asp

HTH

With Best Regards
Naveen K S

"Cathy" wrote:
Hi All,

Can anyone tell me how to create an Excel (.xls) file from a VB.Net app? I
have a SQL Server database that contains a table with the data I want to
export. How do I create the file? Any code samples?

Thanks for your help!

Jul 21 '05 #2
On Wed, 16 Feb 2005 16:55:29 -0500, "Cathy" <cm******@co.dutchess.ny.us> wrote:

Hi All,

Can anyone tell me how to create an Excel (.xls) file from a VB.Net app? I
have a SQL Server database that contains a table with the data I want to
export. How do I create the file? Any code samples?

See if the following works for you:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Orders.xls;Extended Properties=""Excel 8.0;HDR=NO"""

Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(ConnectionString )
ExcelConnection.Open()

Dim ExcelCommand As System.Data.OleDb.OleDbCommand = ExcelConnection.CreateCommand()

ExcelCommand.CommandText = "SELECT * INTO [Orders] FROM [Orders] IN '' [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_ Connection=yes];"
ExcelCommand.CommandType = CommandType.Text
ExcelCommand.ExecuteNonQuery()

ExcelConnection.Close()
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Pravin | last post: by
reply views Thread by Mike | last post: by
1 post views Thread by Eran.Yasso | last post: by
risk32
3 posts views Thread by risk32 | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.