About the Solution

[Previous] [Next]

As I discussed in Chapter 6, most businesses have some set of metrics by which they measure the health of a project, a production process, or the entire company. Often those metrics are fairly stable, and a user needs to examine them only once a day, week, or month. However, occasionally those metrics are exceptionally volatile, changing nearly every second, and spreadsheet models that use them as input need to recalculate as they change. Common examples of real-time metrics include current call loads at a call center, production line reject rates, network server statistics, and financial market information.

To illustrate integrating real-time data into the Spreadsheet component, I built a real-time stock portfolio application. Using this application, you can build a custom stock portfolio and watch the net worth change as prices fluctuate throughout the trading day. (Note that values will not change after the market closes at 4:00 p.m. Eastern time.) Since the solution gets its data from the Microsoft Investor web site (http://www.investor.msn.com), the data is actually delayed by 20 minutes. However, the technique would be exactly the same if you purchased a real-time data feed from the market itself. You can also save your current portfolio to a new local file using Internet Explorer's File|Save As menu command. Although you might think saving the current state of the control should require no additional work, it actually does. I will describe the details and hidden traps of this later in the chapter.

Stock prices have a fairly universal appeal, and it is relatively easy to get stock information (delayed 20 minutes) from the Internet, so this type of data makes for an easy example. However, you can use the same techniques I discuss in this chapter to integrate any type of highly dynamic data. The key is to expose that data as properties of a COM object, which is quite simple using Microsoft Visual Basic.

WARNING
The Spreadsheet component can handle quite a few property bindings in one spreadsheet, but its performance will degrade proportionally to the number of bindings you create. To test the scalability of this feature, I created a Clock object that exposes a Time property. The clock sends a property change notification every second, causing the Spreadsheet control to get the new time value. To start with, I inserted the formula "=document.Clock.Time" into the first cell and let it run for a while. The cell's value updated every second, and everything seemed to work well. I then entered that same formula into 200 spreadsheet cells and let the sample run for a while. The Spreadsheet control handled it, but it took longer than 1 second to process all the change notifications and get all the new values. Instead of seeing the cells update every second, I saw them update every 2 seconds. You should use this technique only when you have few cells to update or when the properties do not change faster than the Spreadsheet control can process the change notifications.



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