ASP and Excel

P

Paxton

I can connect to an Excel worksheet and get records with no problem, if
I know the worksheet's name. However, when my users upload their excel
files, I don't know what the active sheet they want to work from is
called.

I have two options - either force them all to give the saem name to
every worksheet they upload, or providing them with an input field
where they can provide the name of the relevant worksheet

Rather than force my users to name all their worksheets "sheet1", is
there a way I can use ASP to find out the names of the worksheets in a
workbook?

TIA
 
R

Ray Costanzo [MVP]

You could use an ADOX catalog to get the sheet names, but I don't know of
any way to determine which sheet is "first." My guess is that this
definition of what sheet is first is something that is exposed only in the
Excel object model. (Worksheet.Index)

Dim oADOX
Set oADOX = CreateObject("ADOX.Catalog")
oADOX.ActiveConnection = yourADOConnection
For Each oTable in oADOX.Tables
Response.Write oTable.Name & " might be the first table.<br>"
Next

Ray at home
 
M

McKirahan

Paxton said:
I can connect to an Excel worksheet and get records with no problem, if
I know the worksheet's name. However, when my users upload their excel
files, I don't know what the active sheet they want to work from is
called.

I have two options - either force them all to give the saem name to
every worksheet they upload, or providing them with an input field
where they can provide the name of the relevant worksheet

Rather than force my users to name all their worksheets "sheet1", is
there a way I can use ASP to find out the names of the worksheets in a
workbook?

TIA

Will this help? Watch for word-wrap.

This returns the "active sheet".

Option Explicit
Dim strXLA
Dim objXLA
Set objXLA = CreateObject("Excel.Application")
objXLA.Visible = False
objXLA.Workbooks.Open("c:\myExcel.xls")
strXLA = objXLA.ActiveSheet.Name
objXLA.Quit
Set objXLA = Nothing
WScript.Echo strXLA
 
R

Ray Costanzo [MVP]

You don't want to run that server-side... That is HIGHLY ill-advised.

Ray at home
 
P

Paxton

That'll do fine. I don't need to know the order. I'll iterate through
the collection and populate a drop down box.

In the meantime, I'll go and google ADOX and have a little play with
it. Looks like fun :)

Thanks
Paxton
 

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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top