PC Review


Reply
Thread Tools Rate Thread

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

 
 
Cathy
Guest
Posts: n/a
 
      16th Feb 2005
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!


 
Reply With Quote
 
 
 
 
=?Utf-8?B?TmF2ZWVu?=
Guest
Posts: n/a
 
      17th Feb 2005

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!
>
>
>

 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      17th Feb 2005
On Wed, 16 Feb 2005 16:55:29 -0500, "Cathy" <(E-Mail Removed)> 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 ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create a macro to automatically open excel another excel file swain.s@blueyonder.co uk Microsoft Excel Misc 1 20th Jul 2008 09:21 PM
Create new excel files, Save backup of excel file Gil Microsoft Excel Programming 8 9th May 2006 09:40 PM
Drag and drop to create a link to a file in a cell of an Excel file paulaugust2003@yahoo.com Microsoft Excel Discussion 2 18th Sep 2005 03:44 PM
VBA Excel Macro - One File Auto Create Multiple Excel Worksheets! jsamples25 Microsoft Excel Programming 0 22nd Jun 2005 11:16 PM
Can use C# to create and save excel file. But can't reopen the file as it crashes I Decker Microsoft C# .NET 0 31st Jul 2003 04:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:14 PM.