Solved

Creating and Deleting worksheets in Excel usign Visual Studio

Posted on 2010-08-30
1
266 Views
Last Modified: 2013-11-27
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()


0
Comment
Question by:PHFrench
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 33613007
If you need to recreate the worksheet you need to

1) Drop the table

DROP TABLE [Sheet1$]

2) Create the table

CREATE TABLE [Sheet1$]([Full Name] char(255),[Type] char(255),[Date] char(255),[Num] char(255),[Name City] char(255),[Name State] char(255),[Name Zip] char(255),[Memo] char(255),[Name Account #] char(255),[Name] char(255),[UPC Code] char(255),[Item Description] char(255),[Rep] char(255),[Qty] char(255),[Sales Price] char(255),[Amount] char(255))
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question