Click to See Complete Forum and Search --> : Extract Excel cell value into ASP form field
BigJohnson
01-16-2006, 07:26 AM
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.
You can set up a dsn to the excel sheet file and use that as a 'database' that can be called using asp.
BigJohnson
01-17-2006, 03:39 AM
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
%>