Create Excel Worksheet in C# / VB

H

Horst Walter

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

Connection String:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";" +
"Extended Properties=Excel 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
 
M

Miha Markic

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
 
M

Miha Markic

Hi Val,

Val Mazur said:
Hi,

Try to wrap table name into square brackets

CREATE TABLE [S1] ...

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

Horst Walter

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
 
R

Rob Panosh

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
 
P

Paul Clement

¤ 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.aspx?scid=kb;EN-US;Q180841


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
R

Rob Panosh

Thanks...

Rob

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.aspx?scid=kb;EN-US;Q180841


Paul ~~~ (e-mail address removed)
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

Top