Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculated cells in Excel not interacting with Web using ASP 1

Status
Not open for further replies.

grahamrobert

Programmer
Aug 20, 2001
2
IE
Can anyone help!

I am presently creating a web page which interacts with an excel spreadsheet.

I use VBscript to connect to Excel in similar lines to accessing a mdb file.

1. I can read out a recordset (using SQL) from a named area in the spreadsheet and write this in the browser
2. I can update cells in the spreadsheet by using the UPDATE command in SQL
3. I can read out the newly updated cells and write them to the browser....

However any of the cells in the named area that are "calculated cells" do not upate as they should considering the UPDATE command changes their inputs


eg.
page1.asp

Cell 1 5
Cell 2 5
Cell 3(=Cell 1*Cell2) 25

Use a form to update CELL 1 (to 4 say)and post to page2.asp and read out the new recordset

page2.asp

Cell 1 4
Cell 2 5
Cell 3(=Cell 1*Cell2) 25

NB Cell 3 has not updated
 
I'm not sure what you are doing here. If you can send me your code I will take a look at it.

Thanks,

Gabe Condie
 
Gabe,

Here is the code the calculated cell (CELL 2 * CELL3 *4) is the cell that does not come back recalculated

Thnks for taking the interest

EXCELTEST3.ASP


<% @LANGUAGE=&quot;VBScript&quot; %>
<% Option Explicit %>

<%

Dim objConn
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.Open (&quot;TestGDickExcel&quot;)

Dim RS
Dim SQL

SQL = &quot;Select * FROM input;&quot;

SET RS = objConn.Execute(SQL)

If err.number>0 then
response.write &quot;VBScript Errors Occured:&quot; & &quot;<P>&quot;
response.write &quot;Error Number=&quot; & err.number & &quot;<P>&quot;
response.write &quot;Error Descr.=&quot; & err.description & &quot;<P>&quot;
response.write &quot;Help Context=&quot; & err.helpcontext & &quot;<P>&quot;
response.write &quot;Help Path=&quot; & err.helppath & &quot;<P>&quot;
response.write &quot;Native Error=&quot; & err.nativeerror & &quot;<P>&quot;
response.write &quot;Source=&quot; & err.source & &quot;<P>&quot;
response.write &quot;SQLState=&quot; & err.sqlstate & &quot;<P>&quot;



'If you don't receive any errors, then

'you must have connected to the database successfully

Else
response.write &quot;You have successfully connected to the excel spreadsheet.&quot;%>


<html>

<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>New Page 1</title>
</head
<body>
<br>
<p>
<%
While NOT RS.EOF
response.write RS(&quot;Name&quot;)%>... <%
response.write RS(&quot;Value&quot;)%><br><%
RS.movenext
WENd
End If
%>
<form ACTION=&quot; METHOD=GET >

<input type=&quot;text&quot; name=&quot;CELL2&quot; ><font size =&quot;1&quot;>CELL2

<input type=&quot;text&quot; name=&quot;CELL3&quot; ><font size =&quot;1&quot;>CELL3

<p><input type=&quot;submit&quot; value=&quot;Proceed&quot; name=&quot;B1&quot;><input type=&quot;reset&quot; value=&quot;Reset&quot; name=&quot;B2&quot;></p>
</form>

<%
rs.close
Set rs = nothing

objConn.close
Set ObjConn = nothing
%>
<p><a href=&quot;testexcel4.asp&quot;>

exceltest4</a>
<br>
</html>


EXCELTEST4.ASP

<%

Dim objConn1
Set objConn1 = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn1.Open (&quot;TestGDickExcel&quot;)

Dim CELL2
Dim CELL3

CELL2 = Cint(Request.QueryString(&quot;CELL2&quot;))
CELL3 = Cint(Request.QueryString(&quot;CELL3&quot;))

Dim updateSQL
Dim updateSQL1

updateSQL = &quot;UPDATE ID SET ID = '&quot; & CELL2 & &quot;' WHERE Name LIKE 'Jim' &quot;
objConn1.Execute(updateSQL)

updateSQL1 = &quot;UPDATE ID SET ID = '&quot; & CELL3 & &quot;' WHERE Name LIKE 'John' &quot;
objConn1.Execute(updateSQL1)

Dim newSQL
newSQL= &quot;Select * FROM ID;&quot;

Dim newRS
Set newRS = objConn1.Execute(newSQL)

%>

<html>

<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>New Page 1</title>
</head>

<body>

<a href=&quot;testexcel3.asp&quot;>exceltest3</a><br><%

While NOT newRS.EOF
response.write newRS(&quot;ID&quot;)%>... <%
response.write newRS(&quot;Name&quot;)%><br><%
newRS.movenext
WENd


'Close your connection and ensure you're finished using the rs variable.
%>
<p>
<%
newRS.close
Set RS = nothing

objConn1.close
Set objConn1= nothing
%>
</body></html>


ID Name
1 Joe
6 John
5 Jim
120 CELL 2 * CELL3 *4
 
grahamrobert,

Did anyone answer this question? I don't think this is possible because the web page does not have access to you local EXCEL app. You can display the cells but not have a formula to calculate the cells.

If anyone knows how to do this, I have someone else who is also interested in the solution.

fengshui1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top