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

  • Thread starter Thread starter Bill nguyen
  • Start date Start date
B

Bill nguyen

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

Thanks
Bill
 
¤ 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=Microsoft.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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top