Link to home
Start Free TrialLog in
Avatar of PHFrench
PHFrench

asked on

Creating and Deleting worksheets in Excel usign Visual Studio

I want to export data to an existing excel spreadsheet and into a specific worksheet. Each time I will need to delete and then re-create the worksheet. But I do not know what the command is for either. I tried the following to create it and it processed thru without error but i do not see it when I open the spreadsheet (it did not previously exist). I am using Visual Studio 2008.

        Dim SQL1 = "Create Table [TestData2]"

        Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & “c:\test.xls” & ";" & _
        "Extended Properties=""Excel 8.0;HDR=YES""")

        ExcelConnection.Open()
        Dim ExcelCommand As New System.Data.OleDb.OleDbCommand(SQL1, ExcelConnection)
        ExcelCommand.ExecuteNonQuery()


ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial