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

Add-in Express™
for Microsoft® Office and Delphi® VCL

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

Building Excel Real-Time Data servers

Using Add-in Express for Office and VCL you can create Real-Time Data servers for Microsoft Excel 2002 (XP), 2003, 2007 and Excel 2010. You can download this sample Real-Time Data server as well as many other examples from the HowTo page.

Step 1. Creating a new RTD Server project

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 by clicking on the Add-in Express RTD server template in 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.

Entering the project name and destination folder

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

Specifying the RTD server type


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. 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.

RTD server project

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. 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.

RTD topic component properties

Write your code to handle the RefreshData event of the RTD Topic component:


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

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

To debug your add-in in Excel 2010 64-bit, you have to register the add-in DLL using regsvr32; run it from an elevated 64-bit Command Prompt. In addition, you must explicitly specify to run Excel 2010 64-bit in the dialog window shown above.

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 for Office and VCL homepage