By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,497 Members | 2,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,497 IT Pros & Developers. It's quick & easy.

ASP Excel worksheet

P: n/a
Hi,

If I have following code to read the excel file, how do I validate the
worksheets name ? In code below, if the filename doesn't contains "SomeName"
worksheet, I will need to prompt error.
set oConn = server.createobject("adodb.connection")

oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel 8.0"
oConn.Open server.mappath("excel/" & request.querystring("filename"))

strCSVFileName1 = "SomeName$"
Thanks.

Regards.
Jul 27 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
use FSO and check to see if the file exists
Option Explicit

Dim oFSO, message
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(Request.QueryString("filename")) Then
set oConn = server.createobject("adodb.connection") oConn.Provider =
"Microsoft.Jet.OLEDB.4.0"oConn.Properties("Extende d Properties").Value =
"Excel 8.0"oConn.Open server.mappath("excel/" &
request.querystring("filename"))strCSVFileName1 = "SomeName$"message = "The
file exists!"Elsemessage = "The file selected does not exists."End If
Set oFSO = Nothing

hope this helps."magix" <ma***@asia.comwrote in message
news:44**********@news.tm.net.my...
Hi,

If I have following code to read the excel file, how do I validate the
worksheets name ? In code below, if the filename doesn't contains
"SomeName" worksheet, I will need to prompt error.
set oConn = server.createobject("adodb.connection")

oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel 8.0"
oConn.Open server.mappath("excel/" & request.querystring("filename"))

strCSVFileName1 = "SomeName$"
Thanks.

Regards.

Jul 27 '06 #2

P: n/a
I'm not looking for whether the excel file exists or not.
I'm looking into whether the worlsheet called "SomeName$" exists in that
excel file.
"James Jones" <ja**************@insightbb.comwrote in message
news:uo*************@TK2MSFTNGP05.phx.gbl...
use FSO and check to see if the file exists
Option Explicit

Dim oFSO, message
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(Request.QueryString("filename")) Then
set oConn = server.createobject("adodb.connection") oConn.Provider =
"Microsoft.Jet.OLEDB.4.0"oConn.Properties("Extende d Properties").Value =
"Excel 8.0"oConn.Open server.mappath("excel/" &
request.querystring("filename"))strCSVFileName1 = "SomeName$"message =
"The file exists!"Elsemessage = "The file selected does not exists."End If
Set oFSO = Nothing

hope this helps."magix" <ma***@asia.comwrote in message
news:44**********@news.tm.net.my...
>Hi,

If I have following code to read the excel file, how do I validate the
worksheets name ? In code below, if the filename doesn't contains
"SomeName" worksheet, I will need to prompt error.
set oConn = server.createobject("adodb.connection")

oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel 8.0"
oConn.Open server.mappath("excel/" &
request.querystring("filename"))

strCSVFileName1 = "SomeName$"
Thanks.

Regards.


Jul 27 '06 #3

P: n/a
o ok, lol sorry. i misread your post.

sorry, im unable to help with that.
Jay
http://groups.yahoo.com/groups/classicasp/

"magix" <ma***@asia.comwrote in message
news:44**********@news.tm.net.my...
Hi,

If I have following code to read the excel file, how do I validate the
worksheets name ? In code below, if the filename doesn't contains
"SomeName" worksheet, I will need to prompt error.
set oConn = server.createobject("adodb.connection")

oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel 8.0"
oConn.Open server.mappath("excel/" & request.querystring("filename"))

strCSVFileName1 = "SomeName$"
Thanks.

Regards.

Jul 27 '06 #4

P: n/a

magix wrote:
Hi,

If I have following code to read the excel file, how do I validate the
worksheets name ? In code below, if the filename doesn't contains "SomeName"
worksheet, I will need to prompt error.
set oConn = server.createobject("adodb.connection")

oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel 8.0"
oConn.Open server.mappath("excel/" & request.querystring("filename"))

strCSVFileName1 = "SomeName$"

You can iterate through the worksheets using ADOX thus:

<%
Dim oADOX
Set oADOX = CreateObject("ADOX.Catalog")
oADOX.ActiveConnection = yourconnection
For Each oTable in oADOX.Tables
Response.Write oTable.Name
%>

--
Mike Brind
Next

Jul 27 '06 #5

P: n/a

Mike Brind wrote:
magix wrote:
Hi,

If I have following code to read the excel file, how do I validate the
worksheets name ? In code below, if the filename doesn't contains "SomeName"
worksheet, I will need to prompt error.
set oConn = server.createobject("adodb.connection")

oConn.Provider = "Microsoft.Jet.OLEDB.4.0"
oConn.Properties("Extended Properties").Value = "Excel 8.0"
oConn.Open server.mappath("excel/" & request.querystring("filename"))

strCSVFileName1 = "SomeName$"

You can iterate through the worksheets using ADOX thus:

<%
Dim oADOX
Set oADOX = CreateObject("ADOX.Catalog")
oADOX.ActiveConnection = yourconnection
For Each oTable in oADOX.Tables
Response.Write oTable.Name
%>

--
Mike Brind
Next
Ah. My "Next" fell below my sig.

Should have read:

<%
Dim oADOX
Set oADOX = CreateObject("ADOX.Catalog")
oADOX.ActiveConnection = yourconnection
For Each oTable in oADOX.Tables
Response.Write oTable.Name
Next
%>

Jul 27 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.