473,394 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to open an Excel file and save a copy as CSV programatically?

How can I open an Excel file then SAVE AS .CSV file using VB.NET?

Thanks
Bill
Nov 21 '05 #1
2 8575
On Tue, 24 May 2005 21:03:42 -0700, "Bill nguyen" <bi*****************@jaco.com> wrote:

¤ How can I open an Excel file then SAVE AS .CSV file using VB.NET?
¤

You can use ADO.NET to do this:

Dim ExcelConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book20.xls;Extended Properties=""Excel
8.0;HDR=NO;IMEX=1""")

ExcelConnection.Open()

Dim ExportCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Text;DATABASE=E:\My
Documents\TextFiles].[Sheet4.csv] FROM [Sheet4$]")

ExportCommand.ExecuteNonQuery()
ExcelConnection.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #2
Thanks Paul.
I'll try it right away.
Thanks
Bill
"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:67********************************@4ax.com...
On Tue, 24 May 2005 21:03:42 -0700, "Bill nguyen"
<bi*****************@jaco.com> wrote:

¤ How can I open an Excel file then SAVE AS .CSV file using VB.NET?
¤

You can use ADO.NET to do this:

Dim ExcelConnection As New
System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book20.xls;Extended
Properties=""Excel
8.0;HDR=NO;IMEX=1""")

ExcelConnection.Open()

Dim ExportCommand As New System.Data.OleDb.OleDbCommand("SELECT *
INTO [Text;DATABASE=E:\My
Documents\TextFiles].[Sheet4.csv] FROM [Sheet4$]")

ExportCommand.ExecuteNonQuery()
ExcelConnection.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
3
by: VbUser25 | last post by:
hi.. i have a form i accept some user inputs in the form. there is a link on the form from where i open the excel file in the same browser (not in a new page...simply using a href. i am also...
3
by: Jennyfer Barco | last post by:
Hello, I have a question, how can I open Microsoft Excel from .NET. I only need to open a new file in Excel and paste some information and set the Microsoft Excel as the enabled aplication, so the...
3
by: toffee | last post by:
Hi all, I got a pre-formatted spreadsheet. would it be possible using js to copy the data from a table on the current webpage, open the spreadsheet and paste the content ? if so, anyone got any...
0
by: kennedystephen | last post by:
This seems like a simple task. But it's kicking my butt. I have 1 existing excel file. I want to copy the first 50 rows from that excel file, and put them in a new excel file. Then I want to get...
0
by: kennedystephen | last post by:
For the life of me, I cannot get this ... I have 1 excel document. I want to open that document and copy the first 50 rows to a new document. Then get the next 50 rows and copy those to a brand...
8
by: shenkel55 | last post by:
I'm using Access and Excel 2003. Using either the import wizard or code, I have the same problem. This problem only happens with Excel files automatically generated by Corp IT. If I try to do an...
22
by: robertgregson | last post by:
Using C#, .NET3.5, Visual Studio 2008 and WCF on Windows VISTA SP1, I have written a service, service host (as a C# console application) and a client. The service uses...
0
by: chandan | last post by:
Hi, I have written an application for exporting grid data to excel using asp.net and c#.After writting the data in excel I save it in a folder inside my application.After that I invoke the file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.