Solved

Creating and Deleting worksheets in Excel usign Visual Studio

Posted on 2010-08-30
1
262 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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