Worksheet name as part of Data Source parameter

  • Thread starter Thread starter weboweb
  • Start date Start date
W

weboweb

Hi everybody,

When I connect to an Excel data source using Jet 4.0 I use something
like:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\typical.xls ...
extended properties bla bla bla

Is it possible when setting up the connection string to also indicate
the Worksheet Name?
Something like:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\typical.xls[Sheet1]
???

I guess not, but I would like to hear it from the pros. If at all
possible, would somebody please post the correct syntax for this? I
tried the above syntax and it didn't work of course.

What I'm trying to accomplish is that once the connection is made and I
retrieve the schema I would only see information regarding the Sheet1
worksheet and not the whole excel file.

In SQL this would be ridiculous of course, but Excel is so strange
anyway...

It's probably some crazy idea but who knows!

Thanks very much

webOweb
 
Hi everybody,

When I connect to an Excel data source using Jet 4.0 I use something
like:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\typical.xls ...
extended properties bla bla bla

Is it possible when setting up the connection string to also indicate
the Worksheet Name?
Something like:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\typical.xls[Sheet1]
???

I guess not, but I would like to hear it from the pros. If at all
possible, would somebody please post the correct syntax for this? I
tried the above syntax and it didn't work of course.

What I'm trying to accomplish is that once the connection is made and I
retrieve the schema I would only see information regarding the Sheet1
worksheet and not the whole excel file.

In SQL this would be ridiculous of course, but Excel is so strange
anyway...

It's probably some crazy idea but who knows!

Thanks very much

webOweb

Add "$" to the name of the Sheet (SheetName$)
 
From Canary Islands wrote:
Hi everybody,

When I connect to an Excel data source using Jet 4.0 I use something
like:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\typical.xls ...
extended properties bla bla bla

Is it possible when setting up the connection string to also indicate
the Worksheet Name?
Something like:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\typical.xls[Sheet1]
???

I guess not, but I would like to hear it from the pros. If at all
possible, would somebody please post the correct syntax for this? I
tried the above syntax and it didn't work of course.

What I'm trying to accomplish is that once the connection is made and I
retrieve the schema I would only see information regarding the Sheet1
worksheet and not the whole excel file.

In SQL this would be ridiculous of course, but Excel is so strange
anyway...

It's probably some crazy idea but who knows!

Thanks very much

webOweb

Add "$" to the name of the Sheet (SheetName$)

Thanks for the response, but that does not work either (had already
tried that). That would work if I were doing a SELECT * FROM [Sheet1$]
for example, but not as part of the connection string.
What I'm doing now is getting the field count and examining each column
for data type, etc.
I was just wondering if I could apply the OpenSchema to a worksheet
instead of to the whole excel file.

Later!
webOweb
 

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

Back
Top