Create Excel RTD server in .NET: C#, VB.NET, C++

Add-in Express™
for Microsoft® Office and .net

Building Excel RTD servers

Microsoft Excel 2002 provided a new way to view and update data in real time instead of Dynamic Data Exchange (DDE), which is supported by all subsequent versions. This real-time data 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 RTD technology and provides the same RAD way as for COM Add-ins and Smart Tags. For advanced customization of the Excel GUI, Add-in Express also provides Advanced Task Panes and supports Excel Automation add-ins as well as XLL addins for developing custom user defined functions (UDF).

Now we are going to develop a version-independent RTD server for Excel 2007 - 2021. You can also find another example in in the Developer Tutorial: Developing Real-Time Data servers.

See a video tutorial:

1. Create a new Excel RTD Server project

To create a new real-time data server project with Add-in Express, close all opened solutions, choose File | New | Project, select the "Other Projects | Extensibility Projects" item, click the Add-in Express RTD Server icon, and click the OK button.

Project template to create a new RTD server

This will start the wizard that asks you to select a programming language, either C# or VB.NET, and then generates the project.

A new Excel RTD Server project

2. RTD Server module

The project contains an RTD Server module, which is the core part of every Excel RTD Server developed with Add-in Express. The file name for the module is RTDServerModule.vb or RTDServerModule.cs for VB.NET and C# projects respectively. You place RTD Server Topic components onto the module's designer in order to create the information interface of your RTD Server. To add topics to your real-time date server, the module provides a special command available either in the Properties window or in the context menu of the module's designer. Also, you handle RTD Server properties and events in the module.

Adding a new RTD Server Topic component

Refresh interval for the RTD server
Allows specifying if the RTD server should be registered for all users on the PC
When Excel initializes and closes the RTD server

3. Excel RTD Server topics

An RTD Server topic component allows you to specify a part of the information flow provided by the Excel real-time data server. You identify the topic using its properties and handle its RefreshData event.

				Private Function TopicLastPrice_RefreshData(sender As System.Object) As System.Object _
					Handles TopicLastPrice.RefreshData

					Dim actualTopic As AddinExpress.RTD.ADXRTDTopic = _
						CType(sender, AddinExpress.RTD.ADXRTDTopic)
					Dim symbol As String = actualTopic.String02
						If IsValidSymbol(symbol) Then
							Return GetLastPrice(symbol)
							Return "Unknown symbol"
						End If
					Catch ex As Exception
						Return "error"
					End Try
				End Function

Specifying the RTD server topic

String01, String02, ... String28 - these properties allow uniquely identify the topic
The default value for the topic
When the rtd topic is connected and disconnected
When the topic is required to refresh its value

4. Deploying the real-time data server

You deploy and update your Excel RTD server in a variety of ways described in the Developer Tutorial: Step 7. Deploying the RTD server. Your real-time data server can be per-user or per-machine, i.e. for all users on the PC.

You may also be interested in: