How to create an Excel Real-Time Data Server
in Visual Studio .NET - VB.NET, VC++, C#
Add-in Express
for Microsoft .net
Add-in Express Home > Add-in Express.NET > Online Guide > Building Excel RTD servers
Creating RTD servers in Visual Studio .NET
RTD Server is a technology introduced in Microsoft Excel 2002 (XP) and supported in Excel 2003 and 2007 to view and dynamically update data at real time. RTD Servers is a great way to display constantly changing data such as stock quotes, currency exchange rates, etc.
Before we start, make sure you are familiar with the following notions:
- 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.
- Real-time data source is any source of data that can be accessed programmatically.
- Topic is a string (or a set of strings) that uniquely identifies a data source or a piece of data that resides in a real-time data source. The RTD server retrieves the data from the data source and then passes the data to Excel for display. Find more about RTD Server designer.
How to create an Excel Real-Time Data server
With Add-in Express you can develop RTD servers for Excel 2002, 2003 and Excel 2007 in VB.NET, C#, C++ and Chrome. One more sample RTD server project is available.
You may also want to read about special features provided by Add-in Express for creating an advanced Excel GUI with custom task panes, XLL add-ins, Automation add-ins.
Step #1 – Creating a new Add-in Express RTD server project
You create an RTD server project using the Add-in Express RTD Server project template in the New Project dialog.

When you select the template and click OK, the Add-in Express RTD Server project wizard starts. In the wizard window, you choose the programming language and set project options.

This VB.NET sample shows an Add-in Express RTD Server project with the Add-in Express Loader as a shim. To understand shims and the Add-in Express Loader, see Deploying Add-in Express projects.

When the wizard is finished, the RTD Server solution is created and opened in Visual Studio .NET. This solution includes the RTD server project and the setup project.
The RTD server project contains the RTDServerModule.vb (or RTDServerModule.cs) file described in the next step.
Step #2 – RTD Server module
The RTDServerModule.vb (or RTDServerModule.cs) file is an RTD Server module that is the core part of the RTD Server project. The module is a container for ADXRTDTopic components. It contains the RTDServerModule class, a descendant of the ADXRTDServerModule class that implements the IRtdServer interface and allows you to manage server’s topics and their code. To review its source code, in the Solution Explorer window, right-click the RTDServerModule.vb (or RTDServerModule.cs) file and choose the View Code popup menu item.

The code of RTDServerModule.vb is as follows:
Imports System.Runtime.InteropServices
Imports System.ComponentModel
'Add-in Express RTD Server Module
<GuidAttribute("ACD23E21-2F2B-4C13-B894-6C74D8AD2EEE"), _
ProgIdAttribute("MyRTDServer1.RTDServerModule")> _
Public Class RTDServerModule
Inherits AddinExpress.RTD.ADXRTDServerModule
#Region " Component Designer generated code. "
'Required by designer
Private components As System.ComponentModel.IContainer
'Required by designer - do not modify
'the following method
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
End Sub
#End Region
#Region " Add-in Express automatic code "
'Required by Add-in Express - do not modify
'the methods within this region
Public Overrides Function GetContainer() _
As System.ComponentModel.IContainer
If components Is Nothing Then
components = New System.ComponentModel.Container
End If
GetContainer = components
End Function
<ComRegisterFunctionAttribute()> _
Public Shared Sub RTDServerRegister(ByVal t As Type)
AddinExpress.RTD.ADXRTDServerModule.ADXRTDServerRegister(t)
End Sub
<ComUnregisterFunctionAttribute()> _
Public Shared Sub RTDServerUnregister(ByVal t As Type)
AddinExpress.RTD.ADXRTDServerModule.ADXRTDServerUnregister(t)
End Sub
#End Region
Public Sub New()
MyBase.New()
'This call is required by the Component Designer
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
End Class
Step #3 – Add-in Express RTD Server designer
The Add-in Express RTD Server designer allows setting RTD server properties and adding components to the module. In the Solution Explorer window, right-click the RTDServerModule.vb (or RTDServerModule.cs) file and choose the View Designer popup menu item. In the Properties window, you set properties of your RTD Server (see RTD server designer).
|
|
|
To add an Add-in Express Component to the module, you use an appropriate command in the Properties window, or you can right-click the designer surface and choose the same command in the context menu.

The only command available for the module adds the RTD Topic component to the module.
Step #4 – Adding and handling a new topic
To add a new topic to your RTD Server, you use the Add RTD Topic command that adds a new ADXRTDTopic component to the RTD Server Module (see RTD Topic).
Select the server module and, in the Properties window, specify the topic using the String## properties.
|
|
|
To handle the RefreshData event of the RTD Topic, add the RefreshData event handler and write your code to handle the event:
Private Function AdxrtdTopic1_RefreshData( _
ByVal sender As System.Object) As System.Object _
Handles AdxrtdTopic1.RefreshData
Dim Rnd As New System.Random
Return Rnd.Next(2000)
End Function
Step #5 – Running the RTD server
Choose the Register Add-in Express Project item in the Build menu, restart Excel, and enter the RTD function to a cell.
Please note! You need to register the project only when you run it for the first time. To remove the RTD Server from your development PC, unregister it using the Unregister Add-in Express menu item.

Step #6 – Debugging the RTD server
To debug your RTD server, just specify Excel as the Start Program in the Project Options window.

Step #7 – Deploying the RTD server
Just built the setup project, copy all setup files to the target PC and run the setup.exe file to install the RTD Server. See also Deploying Add-in Express projects and Deploying Office add-ins tips.
Back to Add-in Express.NET homepage





