Develop Real-Time Data servers (RTD )
for Excel 2013, 2010, 2007 in Delphi 7 - XE6

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

Excel RTD servers in Delphi

Microsoft Excel 2002 - 2013 provides a new way to view and update data in real time instead of DDE. This Real-Time Data (RTD) feature is really great for working with constantly-changing data such as stock quotes, currency exchange rates, inventory levels, price quotes, weather forecasts, sports scores and so on. Add-in Express supports Real-Time Data servers and Excel user defined functions technologies and provides the same RAD way as for Office COM Add-ins and smart tags.

The sample below demonstrates how to build an RTD server for Microsoft Excel 2013, 2010 and 2007 though earlier Excel versions are supported too. You can find one more example in the developer tutorial: a sample RTD server for Excel 2002-2013.

1. Create a new Excel RTD server project in Delphi

In the Delphi IDE, close all opened projects, select the File|New|Other item on the main menu, and run the MS Excel Real-Time Data Server wizard on the Add-in Express tab of the New Items dialog box:

Create a new Excel RTD Server project in Delphi

In the wizard windows, you enter the name of the project, the destination folder, coclass name, and the server type (DLL or EXE). The wizard generates a new project and opens it in the Delphi IDE.

2. Name your RTD server

The RTDServer module (MyRTDServer1_IMPL.pas) is the heart of the project: it is a placeholder of the RTD Topic component; also, it provides you with RTD server properties.

Setting the RTD Server properties

3. Add a new topic

To add a new RTD topic select the Add-in Express tab on the Component Palette and add adxRTDTopic to the RTDServer module. In the Object Inspector, specify the topic via the StringXX property and handle the OnRefreshData event:

RTD Topic component

Technical information:


			function TRTDServerModule.TopicLastPriceRefreshData(Sender: TObject): OleVariant;
			var
			  actualTopic: TadxRTDTopic;
			  symbol: string;
			begin
			  actualTopic := Sender as TadxRTDTopic;
			  symbol := actualTopic.String02;
			  try
				if IsValidSymbol(symbol) then
				  result := GetLastPrice(symbol)
				else
				  Result := 'Unknown symbol';
			  except
				Result := 'Error';
			  end;
			end;
		
Up to 28 string values identifying the topic
Default value will be used before retrieving the first data
Enabled

4. Register and run your real-time data server

Save the project, compile it, close Excel, and register the server via "Run|Register ActiveX Server". Run Excel and enter the RTD function to a cell:

RTD Server formula in Excel

See also a sample RTD server in .net.