www.webdeveloper.com
Results 1 to 3 of 3

Thread: Extract Excel cell value into ASP form field

  1. #1
    Join Date
    Jul 2004
    Posts
    54

    Extract Excel cell value into ASP form field

    Hi all
    I'd greatly appreciate assistance with this - banging my head around with it!

    Trying to extract the value of a specific XLS sheet into an ASP form field, can this be done?

    eg
    MyXLS.xls - sheet1 - cell a3 ---> Myformfield.

    many thanks.

  2. #2
    Ubik's Avatar
    Ubik is offline <%= "New Meja Hor" %>
    Join Date
    Nov 2005
    Location
    Earth
    Posts
    361
    You can set up a dsn to the excel sheet file and use that as a 'database' that can be called using asp.
    --Ubik

    If I have no idea what you are talking about, then I will pretend I know and answer accordingly.

    Thinking about starting a New Thread entitled 'Please Help Me!' ? Read this!

  3. #3
    Join Date
    Jul 2004
    Posts
    54
    Thanks, I've managed to sort this usingt he following.

    <%
    'Creates an instance of an Active Server Component
    Set oConn = Server.CreateObject("ADODB.Connection")

    'Connects to the Excel driver and the Excel spreadsheet in the directory where the spreadsheet was saved
    strConn = "Driver={Microsoft Excel Driver (*.xls)};DBQ=C:\webalpha\" & strBudgetURL & ";"

    'Opens the connection to the data store
    oConn.Open strConn

    'Selects the records from the Excel spreadsheet
    strCmd = "SELECT * from `feasob`"

    Set oRS = Server.CreateObject("ADODB.Recordset")

    'Opens the recordset
    oRS.Open strCmd, oConn

    'Gets records in spreadsheet as a string and prints them in the table
    strFeasOB_new = oRS.GetString

    oRS.Close
    Set oRS = Nothing

    'Selects the records from the Excel spreadsheet
    strCmd = "SELECT * from `feascb`"

    Set oRS = Server.CreateObject("ADODB.Recordset")

    'Opens the recordset
    oRS.Open strCmd, oConn

    'Gets records in spreadsheet as a string and prints them in the table
    strFeasCB_new = oRS.GetString

    oRS.Close
    Set oRS = Nothing

    oConn.Close
    Set oConn = Nothing
    %>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles