This topic outlines the components of the data feed application, and the data flows between the components.

Components

There are four components involved in providing a real-time data feed in Excel.

Excel

The user enters real-time data formulae in the cells of an Excel spreadsheet. In response, Excel calls the specified add-in functions in the XLL.

XLL

This is an XLL+ Excel add-in, written in C++ by the developer. All the significant code resides here, including the following:

  • User-friendly add-in functions which return real-time data. These functions are responsible for transforming the user's input into the form required to query the data feed.
  • An event-handler function which responds to "update" messages from the data feed.
  • Event-handler functions that respond to the Excel events that are raised when (i) a topic is removed from a spreadsheet, and (ii) an old topic is requested when a spreadsheet containing real-time data is reopened.
RTD Server

An RTD (Real-Time Data) server module is a means of extending Excel so that it can respond quickly and reliably to data that changes in the outside world. An RTD server must be provided as a COM module and must support the COM interface IRtdServer.

The XLL+ data feed server is an RTD server provided as part of the XLL+ tool-kit (version 6.3 and above). The file is named XllRtdFeed.dll and can be found in the bin sub-directory of the XLL+ installation directory.

Data Feed

A 3rd-party data feed with a C++ API is the final component. Typically, the API of such a feed will allow an application (in this case, the XLL) to do the following:

  • Initialize and terminate a connection to the data feed.
  • Request the latest value of a data item.
  • Register interest in a data item, so that the application will be informed, via a call-back function, whenever the data item's value is updated. This action is often referred to as "Advise".
  • Inform the data feed that the application is no longer interested in a particular data item (often called "Unadvise").

The data feed supplied as part of the sample application is simple and very limited, and is provided only to demonstrate the techniques for writing an add-in that uses it. It is described in more detail in Demo Feed server.

As you will see in the following section, Flows, the data flows required to manage real-time data in Excel can be quite complicated. The XllRtdFeed RTD server and the C++ API supplied in XllRtdFeedServerProxy.h abstract most of this complexity and make the process of developing a data feed add-in much simpler.

Flows

The data flow between Excel and the various components of a real-time feed is described below.

Excel calls add-in function

The data feed sends an update

A spreadsheet containing real-time data is reopened

When a spreadsheet is opened that contains real-time data formulae, Excel may need to refresh the real-time values. The following steps occur:

  1. Excel informs the RTD server that it wants up-to-date values for the topics used in the spreadsheet.

  2. The RTD informs the XLL by invoking the IXllRtdFeedCallback::OnGetDataState() event handler function, which is implemented in the XLL.

  3. During IXllRtdFeedCallback::OnGetDataState(), the XLL requests the latest value of the data item from the data feed.

  4. The feed either returns the current value for the data, or returns a success code, indicating that the data will be sent later, asynchronously.

  5. The XLL's implementation of IXllRtdFeedCallback::OnGetDataState() returns a state value which describes the current value of the requested data item.

  6. The RTD server returns the state value to Excel. Excel compares it to the last state value it received for this data item, and decides whether the value is out of date.

After this, Excel will call the add-in function again for any cell that refers to the reopened topic, and the data flow will be as discussed above under Excel calls add-in function.

See Also

Other Resources