473,804 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create Excel Worksheet in C# / VB

I create an Excel worksheet in C# (should be similar in VB)

Connection String:
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + filename + ";" +
"Extended Properties=Exce l 8.0;";

Create string:
"CREATE TABLE S1 (Dt date, St char(40), Cr currency)"

Works fine, but the worksheet is named _S1 (UNDERSCORE!) and not S1.
Why does this happen? Any ideas?

Thx HW
Nov 15 '05 #1
8 13960
Hi Horst,

Wild guessing here: maybe iit s some sort of reserved word (i think it is
afraid of cell naming...).
Try with other names - they should work

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Horst Walter" <un***@web.de > wrote in message
news:53******** *************** **@posting.goog le.com...
I create an Excel worksheet in C# (should be similar in VB)

Connection String:
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + filename + ";" +
"Extended Properties=Exce l 8.0;";

Create string:
"CREATE TABLE S1 (Dt date, St char(40), Cr currency)"

Works fine, but the worksheet is named _S1 (UNDERSCORE!) and not S1.
Why does this happen? Any ideas?

Thx HW

Nov 15 '05 #2
Hi,

Try to wrap table name into square brackets

CREATE TABLE [S1] ...

--
Val Mazur
Microsoft MVP
Check Virus Alert, stay updated
http://www.microsoft.com/security/incident/blast.asp

"Horst Walter" <un***@web.de > wrote in message
news:53******** *************** **@posting.goog le.com...
I create an Excel worksheet in C# (should be similar in VB)

Connection String:
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + filename + ";" +
"Extended Properties=Exce l 8.0;";

Create string:
"CREATE TABLE S1 (Dt date, St char(40), Cr currency)"

Works fine, but the worksheet is named _S1 (UNDERSCORE!) and not S1.
Why does this happen? Any ideas?

Thx HW

Nov 15 '05 #3
Hi Val,

"Val Mazur" <gr******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Try to wrap table name into square brackets

CREATE TABLE [S1] ...


It doesn't work (already tried that :) ). Also parenthesis have no effect...

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
Nov 15 '05 #4
Thanks for your answers.
As a matter of fact, the name S1 seems to be the problem.

Summary:
========
This works:
CREATE TABLE mytable (Dt date, St char(40), Cr currency)

CREATE TABLE S1 (Dt date, St char(40), Cr currency)
=> Worksheet's name will be _S1

CREATE TABLE [S1] (Dt date, St char(40), Cr currency)
does not work

Google index
C# Excel worksheet underscore

un***@web.de (Horst Walter) wrote in message news:<53******* *************** ***@posting.goo gle.com>...
I create an Excel worksheet in C# (should be similar in VB)

Connection String:
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + filename + ";" +
"Extended Properties=Exce l 8.0;";

Create string:
"CREATE TABLE S1 (Dt date, St char(40), Cr currency)"

Works fine, but the worksheet is named _S1 (UNDERSCORE!) and not S1.
Why does this happen? Any ideas?

Thx HW

Nov 15 '05 #5
Horst,

Don't mean to jump on on your thread here but I have a question for you. Do
you know where I can find documentation for Excel when creating tables using
ADO.Net? i.e. - datatypes and general syntax ...

Thanks,
Rob Panosh

"Horst Walter" <un***@web.de > wrote in message
news:53******** *************** **@posting.goog le.com...
I create an Excel worksheet in C# (should be similar in VB)

Connection String:
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + filename + ";" +
"Extended Properties=Exce l 8.0;";

Create string:
"CREATE TABLE S1 (Dt date, St char(40), Cr currency)"

Works fine, but the worksheet is named _S1 (UNDERSCORE!) and not S1.
Why does this happen? Any ideas?

Thx HW

Nov 15 '05 #6
On Mon, 5 Jan 2004 07:10:17 -0600, "Rob Panosh" <ro************ ************@as dsoftadfdware.c om>
wrote:

¤ Horst,
¤
¤ Don't mean to jump on on your thread here but I have a question for you. Do
¤ you know where I can find documentation for Excel when creating tables using
¤ ADO.Net? i.e. - datatypes and general syntax ...
¤

You should be able to use the Jet database provider DDL syntax:

HOWTO: Common DDL SQL for the Microsoft Access Database Engine
http://support.microsoft.com/default...;EN-US;Q180841
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 15 '05 #7
Try this:

http://www.kjmsolutions.com/datasetarray.htm

This will write the dataset to an array and then to an excel spreadsheet.

Also, solutions like these can be found by using the VB.NET/ADO.NET free
search engine tool at
http://www.kjmsolutions.com/newsgrouptool.htm
"Rob Panosh" <ro************ ************@as dsoftadfdware.c om> wrote in
message news:um******** ******@TK2MSFTN GP09.phx.gbl...
Horst,

Don't mean to jump on on your thread here but I have a question for you. Do you know where I can find documentation for Excel when creating tables using ADO.Net? i.e. - datatypes and general syntax ...

Thanks,
Rob Panosh

"Horst Walter" <un***@web.de > wrote in message
news:53******** *************** **@posting.goog le.com...
I create an Excel worksheet in C# (should be similar in VB)

Connection String:
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" + filename + ";" +
"Extended Properties=Exce l 8.0;";

Create string:
"CREATE TABLE S1 (Dt date, St char(40), Cr currency)"

Works fine, but the worksheet is named _S1 (UNDERSCORE!) and not S1.
Why does this happen? Any ideas?

Thx HW


Nov 15 '05 #8
Thanks...

Rob

"Paul Clement" <Us************ ***********@sws pectrum.com> wrote in message
news:6e******** *************** *********@4ax.c om...
On Mon, 5 Jan 2004 07:10:17 -0600, "Rob Panosh" <ro************ ************@as dsoftadfdware.c om> wrote:

¤ Horst,
¤
¤ Don't mean to jump on on your thread here but I have a question for you. Do ¤ you know where I can find documentation for Excel when creating tables using ¤ ADO.Net? i.e. - datatypes and general syntax ...
¤

You should be able to use the Jet database provider DDL syntax:

HOWTO: Common DDL SQL for the Microsoft Access Database Engine
http://support.microsoft.com/default...;EN-US;Q180841
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)

Nov 15 '05 #9

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

Similar topics

13
35569
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 and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
4
20506
by: Krishna Tulasi via .NET 247 | last post by:
Hi, I am having trouble with creation of XML programmatically using .NET. Specifically Im trying to create an element which looks like below and insert into an existing xml doc: <Worksheet ss:Name="TKCSheet1"> </Worksheet> The existing xml doc is: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?>
1
4696
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have written the driver prg in c#. The code opens the file, but it is not writting the values from text file into excel file. I can not figure out the problem here. This is my code: StreamReader dataFileReader = null; FileInfo file = null;...
1
10748
by: javzxp | last post by:
Hi I'd like to use C# to open an existing Excel workbook and save each worksheet it contains into a new Excel file. The name of each new Excel file should be the name of the worksheet copied from the existing file. So, as an example:
7
11588
by: KC | last post by:
Does anybody know how to add a specific number of worksheets to an Excel spreadsheet through VB.net? I'm trying to export some datatables to an excel file, but I only want as many sheets in the workbook as there are tables. Right now the routine I'm tweaking from http://support.microsoft.com/default.aspx?scid=kb;EN-US;306022 adds the default, (3).
3
10751
by: James Wong | last post by:
Dear all, I have an old VB6 application which can create and access Excel object. The basic definition statements are as follows: Dim appExcel As Object Dim wkb1 As Excel.Workbook Dim wks1 As Excel.Worksheet Set appExcel = New
1
2581
by: Randall Arnold | last post by:
I'm converting a vbscript program to vb.net. Witht he exception of .net idiosyncrasies, most of it is working well with the same code. My only problem is that some properties and methods are missing from the Chart object. For instance, the following line worked fine in vbscript (csPowerSpeed is the chart): objXL.csPowerSpeed.seriescollection.newseries() However, in VS.Net, newseries is no longer avaialable as a method for series...
9
13837
by: John Brock | last post by:
I am trying to create a workbook where one of the worksheets contains an AutoFiltered table. It looks like it should be simple -- what I am doing is this: rng = ws.Range("MyTableRange") rng.AutoFilter() Unfortunately I get an exception on the second statement, with the unhelpful message:
1
3385
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons: 1) export to excel button exports the visible columns from the datagridview to excel (this works fine)
0
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.