IIS ASP - ASP Excel worksheet

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > July 2006 > ASP Excel worksheet





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ASP Excel worksheet
magix

2006-07-27, 1:26 pm

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.


James Jones

2006-07-27, 1:26 pm

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("Extended 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" <magix@asia.com> wrote in message
news:44c8e1a3$1_2@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.
>



magix

2006-07-27, 1:26 pm

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" <jamisonburrous08@insightbb.com> wrote in message
news:uoOynjZsGHA.452@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("Extended 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" <magix@asia.com> wrote in message
> news:44c8e1a3$1_2@news.tm.net.my...
>
>



James Jones

2006-07-27, 1:26 pm

o ok, lol sorry. i misread your post.

sorry, im unable to help with that.


Jay


http://groups.yahoo.com/groups/classicasp/





"magix" <magix@asia.com> wrote in message
news:44c8e1a3$1_2@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.
>



Mike Brind

2006-07-27, 7:24 pm


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

Mike Brind

2006-07-27, 7:24 pm


Mike Brind wrote:
> magix wrote:
>
> 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
%>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com