Returning an Interactive Spreadsheet Component

[Previous] [Next]

If the client browser supports COM controls (indicated by the ActiveXControls property of the BrowserType object), I allow the user to request an interactive Spreadsheet control containing the results of his or her mortgage calculation. The code to output this is amazingly easy:

         ' Write an object tag for the Spreadsheet control         ' and a couple parameter tags to tell it where the model is         Response.Write "<object " & _             "classid=""clsid:0002E510-0000-0000-C000-" & _             "000000000046"" style=""width:100%;height:75%;""" & _             "id=ssMort>"         Response.Write "<param name=HTMLURL value=""Mortgage.htm"">"         Response.Write "<param name=DataType value=""HTMLURL"">"         Response.Write "</object>"         Response.Write "<script language=vbscript>"         Response.Write "ssMort.ActiveSheet.Range(""B2:B6"").Value="         Response.Write "Array(" & m_nPrice & "," &  m_nPctDown & "," & _             m_nRate & "," & m_nYears & "," & _             m_nAddPayment & ")"         Response.Write "</script>" 

To cause the browser to load an interactive Spreadsheet control into the page, I simply have to write back an <object> tag with the appropriate COM class ID. To tell the Spreadsheet control from where to load the model, I include two <param> tags, one specifying the relative URL to the Mortgage.htm spreadsheet model and another telling the Spreadsheet to use this instead of expecting an HTMLData <param> tag. Because the HTMLURL property loads via HTTP and a URL, the Spreadsheet control can load the same file I used on the web server.

The only remaining task is pushing the loan variables into the Spreadsheet control so that it will recalculate the mortgage information based on the inputs. I do that by emitting the same code I used to push the values into the Spreadsheet component on the server, and since this script executes as soon as it is parsed, the new values are almost instantly set into the Spreadsheet control.



Programming Microsoft Office 2000 Web Components
Programming Microsoft Office 2000 Web Components (Microsoft Progamming Series)
ISBN: 073560794X
EAN: 2147483647
Year: 1999
Pages: 111
Authors: Dave Stearns

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net