This project includes a demo showing integration between Lightstreamer .NET/C# Client and RTD Server for Excel
C#
Latest commit 991eff9 Jan 24, 2017 @Bravo27 Bravo27 Update API doc link

README.md

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.

Live Demo

screenshot

View live demo

(download RTDLibraryExcelDemoSetup.msi; launch it; follow the instructions)

Details

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

Install

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.zip file that you can find in the deploy release of this project and extract the application installer (a .msi file).
  • Execute the downloaded file to install the application.
  • From the Start menu, go to the Lightstreamer RTD Demo folder, and click the "Start Lightstreamer Excel RTD Server Demo" link. This will open Excel and automatically load the ExcelDemo_local.xlsx spreadsheet (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.

Build

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.dll and Lightstreamer_DotNet_PCL_Client.pdb from NuGet Lightstreamer.DotNet.Client or use directly the Package Manager Console Install-Package Lightstreamer.DotNet.Client). 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 RTDServiceRegistrationExample.reg file.

Run

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

Deploy

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:

=RTD("lightstreamer.rtdexceldemo";;"CONFIG";"http://push.lightstreamer.com";"80";"DEMO";"QUOTE_ADAPTER")

See Also

Lightstreamer Adapters Needed by These Demo Clients

Related Projects

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.