Building RTD servers for Excel 2007, 2003, 2002.
Excel Real-Time Data server in Delphi 5 - 2007.

Add-in Express
for Borland VCL


Add-in Express Home > Add-in Express VCL > Online Guide > Developing Excel RTD servers

Excel Real-Time Data servers

How to develop COM add-ins, smart tags, RTD servers in Delphi - Flash video Microsoft Excel 2002 (XP), Excel 2003 and Excel 2007 provide a new way to view and update data in real time. This real-time data (RTD) feature is very useful when dealing with constantly changing data such as stock quotes, currency exchange rates, inventory levels, price quotes, airline reservations, weather information, sports scores, and so on.

Before we start, make sure you are familiar with the notion of a real-time data source, an RTD server, and a topic.

  • Real-time data source - any source of data that can be accessed programmatically.
  • Real-Time Data server (RTD server) is a Component Object Model (COM) Automation server that implements the IRtdServer interface. Excel uses the RTD server to communicate with a real-time data source.
  • A topic is a string (or a set of strings) that uniquely identifies a piece of data that resides in a real-time data source. The Real-Time Data server passes the topic to the real-time data source and receives the value of the topic from the real-time data source; the RTD server then passes the value of the topic to Excel for display. For example, the RTD server passes the topic "NewTopic" to the real-time data source, and the RTD server receives the topic's value of "72.12" from the real-time data source. The RTD server then passes the topic's value to Excel for display.

Are RTD servers available on Add-in Express VCL? Yes, let's go. The sample RTD project below is for Microsoft Excel 2002 (XP) and 2003. If you develop for Office 2007, see a sample RTD server project for Excel 2007.

Step #1 - Running the RTD Server project wizard

In the Delphi IDE, close all opened projects, select the File | New | Others item of the main menu, and run the Add-in Express Excel RTD Server wizard on the Add-in Express VCL tab of the "New Item" dialog box.

Creating a new RTD server project
 
In the RTD Server Project wizard window, enter the name of the project and the destination folder for it, and click Next.

RTD server wizard
 
Then specify the server type, the coclass name of your server, click Next and Finish.

RTD server solution


The wizard generates a new project and opens it in Delphi IDE. The Real-Time Data server project includes the following items:

  • The project source files (ProjectName.*)
  • The type library files: binary (ProjectName.tlb) and Object Pascal unit (ProjectName_TLB.pas)
  • The RTD server module (ProjectName_IMPL.pas and ProjectName_IMPL.dfm) discussed in the next step.

Step #2 – Looking at Add-in Express RTD Server module

The RTD server module (MyRtdServer1_IMPL.pas and MyRtdServer1_IMPL.dfm) is the core part of the RTD Server project. The module is a container for TadxRTDTopic components.
The code of MyRtdServer1_IMPL.pas is as follows:


unit MyRtdServer1_IMPL;
interface
uses
  SysUtils, Classes, ComServ, MyRtdServer1_TLB, adxRTDServ;
type
  TcoMyRtdServer1 = class(TadxRTDServer, IcoMyRtdServer1);
  TRTDServerModule = class(TadxXLRTDServerModule)
  private
  protected
  public
  end;
implementation
{$R *.dfm}
initialization
  TadxRTDFactory.Create(ComServer, TcoMyRtdServer1, CLASS_coMyRtdServer1, TRTDServerModule);
end.

Step #3 – Using Add-in Express RTD Server designer

The module designer allows setting RTD Server properties and adding components to the module.
You set the properties of your RTD server module in the Object Inspector window.

Setting the properties of the RTD server
 
The only Add-in Express component available for the module is the TadxRTDTopic component.

Step #4 – Adding and handling a new topic

To add a new topic to your RTD Server, in the Tool Palette, select the Add-in Express tab and drag-n-drop the TadxRTDTopic component onto the RTD Server Module.

RTD topic component
 
Select the newly added RTD topic component and, in the Object Inspector window, identify the topic using the String## properties.

TRD topic component properties

Now, handle the RefreshData event of the topic:


function TRTDServerModule.adxRTDTopic1RefreshData(Sender: TObject): OleVariant;
begin
  Result := RandomRange(-100, 100);
end;

Step #5 – Running the RTD server

Choose the Register ActiveX Server item in the Run menu, restart Excel, and enter the RTD function to a cell. 

Running the RTD server

You refer to an existing RTD Server using the RTD worksheet function in Excel:

=RTD(ProgID, Server, String1, String2, ... String28)

The ProgID parameter is a required string value representing the programmatic ID (ProgID) of the RTD server. The current version of Add-in Express requires the Server parameter to be an empty string. Use two quotation marks (""). The String1 through String28 parameters represent topics of the RTD server. Only the String1 parameter is required; the String2 through String28 parameters are optional. In most cases, the String1 parameter will be enough for you. The actual values for the String1 through String28 parameters depend on the requirements of the real-time data server.

Step #6 – Debugging the RTD server

To debug your Real-Time Data server, just indicate Excel as the Start Program in the Project Options window.

Debugging the RTD server

Step #7 – Deploying the RTD server

Make sure your setup project registers the RTD Server DLL (or EXE). Say, in Inno Setup projects you use the 'regserver' command.

Writing smart tags <<

>> Excel Automation add-ins

Back to Add-in Express VCL homepage




Client login

 

Login 

Password 

 

Remember me

Forgot my password