Last month, we showed you how to quickly create an intuitive data entry form with our Spreadsheet control. In July, we showed you how to incorporate a rich text editor for worksheet cell editing. In this post, we will review the calculation/computational capabilities of our WinForms and WPF Spreadsheet controls.
As you may already know, DevExpress Spreadsheet for both the WinForms and WPF platforms supports over 400 built-in functions designed to address a broad range of usage scenarios. You can use basic mathematical functions to aggregate data within a spreadsheet or create complex formulas with statistical, engineering, and financial functions for advanced data analysis.
The focus of this post is an important function called RTD - a function that allows you retrieve data from real-time data servers. To help demonstrate the ease with which you can use RTD, we’ll show you how to use this function to create the following simple stock analysis dashboard.
What is the RTD function?
The RTD (Real-Time Data) function retrieves data in real time from programs that support COM automation. Financial apps use this function to pull market data from various financial service data providers (Yahoo! Finance, Google Finance, Bloomberg, etc.) into spreadsheets.
The RTD function contains the following syntax:
RTD(ProgID, ServerName, Topic1, [Topic2], ...)
- ProgID: The data server's programmatic ID.
- ServerName: The name of the machine on which the real-time data server is running. If the RTD server is running locally, ServerName is an empty string or can be omitted.
- Topic1, [Topic2], ... Specifies the data to retrieve from the real-time data server.
How to use the RTD function within the DevExpress Spreadsheet control
- Run Visual Studio as an administrator and create a new Spreadsheet application (WinForms or WPF).
Specify a real-time data server. In this example, we use a custom COM Automation server that implements the IRtdServer interface. Our server provides data for stock prices, number of shares, and price change.
Specify a unique GUID and ProgID for the server and add the ComVisible(true) attribute to make the created server COM-visible.
View our RTD Server implementation.
Open the project's properties, and select the Register for COM interop check box on the Build tab. This option automatically registers our COM server when the project is compiled.
Use the Spreadsheet’s RTD function to retrieve data (from the server) into worksheet cells. Our RTD function requires two topics (said differently, it will request two items from the server): a ticker symbol and stock information.
The following properties allow you to control real-time data updates:
- SpreadsheetControl.Options.RealTimeData.RefreshMode Specifies whether to update data manually via the RealTimeData.RefreshData method or to use a timer for automatic updates;
- SpreadsheetControl.Options.RealTimeData.ThrottleInterval Specifies the time interval between automatic updates.
Once you’ve retrieved the necessary data, you can use the Spreadsheet charts and conditional formatting to better visualize information and highlight data trends for your end users.
If you are ready to get started, feel free to download a complete sample project from https://github.com/DevExpress-Examples/how-to-implement-real-time-data-server-and-use-rtd-worksheet-function-e5204.
We Want to Hear from You
If you’re currently using RTD functions or are considering its use in a future project, please post your feedback/thoughts below. We’d love to learn more about your usage scenarios and the real-time data servers you use within your app.
Should you have technical questions, feel free to contact us via the DevExpress Support Center.