Lightstreamer - Basic Stock-List Demo - Excel (RTD) Client
This project includes a demo client showing integration between .NET PCL client API for Lightstreamer and RTD Server for Excel.
(download RTDLibraryExcelDemoSetup.msi; launch it; follow the instructions)
Real-Time Data (RTD) is a technology introduced in Microsoft Excel starting from 2002, aimed at replacing DDE for updating spreadsheets in real-time.
This demo is made up of a DLL library that acts as an RTD Server, which receives updates from Lightstreamer Server on one side and injects them into Excel on the other side. The library has been developed with C#.NET (full source code is provided, see below). It leverages the .NET PCL Client API for Lightstreamer to subscribe to 30 stock items and the Microsoft Office library to set up the RTD server.
The control windows shows a counter with the updates received from Lightstreamer Server and logs such updates in real-time. Is also shows the notifications issued toward Excel. To pause the notification calls, uncheck "Data stream to Excel".
Dig the Code
The main class is RtdServer, found in RtdServer.cs, which contains an implementation of the IRtdServer interface. The same class will load a Form showing information regarding Lightstreamer updates coming in and Excel updates pushed out. LightstreamerClient.cs, StocklistConnectionListener.cs, and StocklistHandyTableListener.cs contain classes used to interface to the Lightstreamer .NET PCL Client library, as seen in the .NET StockListDemo project.
Check out the sources for further explanations.
NOTE: Not all the functionalities of the Lightstreamer .NET/C# Client & Local RTD Server for Excel demo are exposed by the classes listed above. You can easily expand those functionalities using the PCL/C# Client API as a reference: http://www.lightstreamer.com/api/ls-pcl-client/latest/.
If you want to install a version of this demo pointing to your local Lightstreamer Server, follow these steps:
- Note that, as prerequisite, the Lightstreamer - Stock- List Demo - Java Adapter has to be deployed on your local Lightstreamer Server instance. Please check out that project and follow the installation instructions provided with it.
- Launch Lightstreamer Server.
- You need Microsoft Excel 2007 or newer installed on your Windows PC.
- Download the
deploy.zipfile that you can find in the deploy release of this project and extract the application installer (a
- Execute the downloaded file to install the application.
- From the Start menu, go to the
Lightstreamer RTD Demofolder, and click the "Start Lightstreamer Excel RTD Server Demo" link. This will open Excel and automatically load the
ExcelDemo_local.xlsxspreadsheet (which, by the way, is contained in
C:\Program Files (x86)\Lightstreamer .NET RTD Server Demo library for Excel\).
- The spreadsheet will activate the Lightstreamer RTD library, which will open a control window, where you can see the data traffic.
In the Excel spreadsheet, you will see several cells changing in real-time. If the update rate looks slow (that is, you don't see several updates in a second), it means that the RTD ThrottleInterval of Excel is set to a high value. To activate real-time dispatching, please follow these instructions:
- In Excel, go to the Visual Basic Editor (by pressing ALT+F11 or clicking Visual Basic Editor from the Macro menu (Tools menu).
- Open the Immediate window (press CTRL+G or click Immediate Window on the View menu).
- In the Immediate window type this code and press ENTER: Application.RTD.ThrottleInterval = 0.
To build your own version of the demo, instead of using the one provided in the
deploy.zip file from the Install section above, follow these steps:
To compile the project, a version of Excel implementing RTD features must be installed (usually Excel 2007, 2010+). For more information regarding the RTD technology, please visit this page. For more information regarding Visual C# 2010 Express and how to run it, please go to: http://www.microsoft.com/express/Downloads/#2010-Visual-CS.
NOTE: You may also use the sources included in this project with another Microsoft IDE or without any IDE but such an approach is not covered in this readme.
You just need to create a Visual Studio project for a Class library (DLL) target, then include the sources and properties files and include references to the Microsoft.Office.Interop.Excel and
Lightstreamer.NET PCL Client API (get the binaries files binaries files of the library
Lightstreamer_DotNet_PCL_Client.pdb from NuGet Lightstreamer.DotNet.Client or use directly the Package Manager Console
After the compilation of your DLL, you need to run
RegAsm.exe tool to register it against COM.
RegAsm.exe is part of the .NET SDK and just generates some Registry entries, like the ones in the example
RTDLibraryExcelDemo.dll is registered,
ExcelDemo.xlsx has to be opened.
If the registration was successful, Excel will load
RTDLibraryExcelDemo.dll, a status window will appear, and real-time data will start to be delivered to it. A quick and easy way to avoid dealing with Registry entries is to install the shipped version of the library with the downloadable RTDLibraryExcelDemoSetup.msi, then just
compile your own
.dll, replacing the one installed.
Please note that the RTD technology works on top of DCOM, this means that you could even deploy a centralized remote RTD Server that can be used across your network. In the case of this demo, both RTD Server and Excel will run on the same local computer.
Internet connection is required to make the RTD Server, controlling a Lightstreamer connection, being able to deliver real-time data to Excel.
Obviously, you could test the application against your Lightstreamer server installed somewhere, but in this case, you have to change the paramters of RTD function in
A1 cell of the Excel sheet; please note the fourth and fifth parameters:
Lightstreamer Adapters Needed by These Demo Clients
- Lightstreamer - Stock-List Demo - Java Adapter
- Lightstreamer - Reusable Metadata Adapters - Java Adapter
- Lightstreamer - Stock-List Demos - HTML Clients
- Lightstreamer - Basic Stock-List Demo - jQuery (jqGrid) Client
- Lightstreamer - Stock-List Demo - Dojo Toolkit Client
- Lightstreamer - Basic Stock-List Demo - .NET Client
- Lightstreamer - Basic Stock-List Demo - Java SE (Swing) Client
Lightstreamer Compatibility Notes
- Compatible with Lightstreamer .NET PCL Client Library version 3.0.0 or newer.
- For Lightstreamer Allegro (+ .NET Client API support), Presto, Vivace.