472,962 Members | 2,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,962 software developers and data experts.

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 12441

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pravin | last post by:
Hi, I want to know the APIs provided for c++ (By any OS) to convert a file from .xls to .xml format. Or if there is any tutorial or code snipped already there in net, will also do. Pravin.
0
by: New comer | last post by:
Hi I'd like to know how to use c# form to call excel file. Like when I click a button, the .xls file opened, and some data in the textboxes put into the excel cells. Thanks
2
by: Cathy | last post by:
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...
0
by: Mike | last post by:
Hi, Does any body using Aspose.Cells? Any recommendation, bugs, easy to use? Thanks, Michael
1
by: Eran.Yasso | last post by:
Hi, Can anyone please tell me how can i create xls file? i then need to write to it. I am creating the file using File.Create(file.xls); but ican't acces the file. i gt error that the file is...
1
by: treybraid | last post by:
My Flash file is a GameCenter where team standings are kept.. I have it set up right now with the master spreadsheet programmed that is linked to a dummy sheet that is saved as a CVS doc and loaded...
2
by: treybraid | last post by:
My Flash file is a GameCenter where team standings are kept.. I have it set up right now with the master spreadsheet programmed that is linked to a dummy sheet that is saved as a CVS doc and loaded...
3
by: PW | last post by:
Does the worksheet have to be exported to a CSV file first or can Access import directly from an Excel workbook (.xls)? Thanks, -paulw
3
risk32
by: risk32 | last post by:
As far as I know, this has been tried MANY times without success. Or, at least without the Web Components loaded on a server. But, I'll go ahead and ask just in case someone can point me in the right...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.