Beginner documentation for Dna/RTD?

Jan 29, 2014 at 6:16 PM
Is there a page with some documentation that explains how to set up Excel-DNA with an RTD server?

I see some examples, and I know it's supported, but they seem to skip over some of the setup stuff that I'd like to know more about.

For instance, there's this example here, but it seems to be a few steps past the kind of really simple illustrative example that would really help me out.
http://exceldna.codeplex.com/SourceControl/latest#Distribution/Samples/RTD/Readme.txt

Why is all the CS code embedded in dna xml files? Can't I just use regular *cs files?

Thanks
-Grant
Coordinator
Jan 29, 2014 at 6:56 PM
Hi Grant,

If you plan to use C# for your Excel-DNA add-in, one approach to get started is by following the detailed step-by-step instructions (with screenshots) in the Distribution directory. If you're already comfortable with the NuGet package manager, it's even easier - you just Install-Package Excel-DNA and follow the Readme instructions that will pop up.

The code in the ExcelRtdServer.dna file (https://exceldna.codeplex.com/SourceControl/latest#Distribution/Samples/RTD/ExcelRtdServer.dna) would be a good start for an RTD server. It shows how to make a ticking RTD server based on Timer events. Basically you just create a class that derives from ExcelRtdServer and override the ConnectData (and possibly other) methods. Then call Topic.UpdateValue(...) when data changes. Finally set up some wrapper functions that call XlCall.RTD(...) to expose to the user.

To integrate the RTD server in a working C# add-in, create a new file and copy the stuff in from the sample. (You probably have to uncomment the [ComVisible(true)] line.

As an alternative RTD implementation, Excel-DNA also supports exposing Rx-style IObservables to Excel as real-time sources. But for this you'd need to be familiar with the Rx library first.

I made the .dna files so that it is easy to create an add-in with some code, and not need to compile a project. That's pretty helpful for making standalone little tests and examples. Excel-DNA also supports using compiled projects, and even having loose .cs source files that compile at load time. But these need a few files for every example, while a single .dna file is complete. The functionality supported by Excel-DNA is all these cases is exactly the same.

If you have more specific questions, or if you get stuck trying to make any of this work, please write back.

Regards,
Govert
Jan 29, 2014 at 8:51 PM
Thanks, I was able to figure it out with an IRtdServer (based on prior experience doing it the hard way).

Then I converted it to use ExcelRtdServer, which seems to be working well.

It'd be nice if that example directory was thinned out a bit, and maybe some more direction could be given. There's a lot of stuff in there that I think distracts from the core that a newbie like me needs to figure out to get rolling.
Coordinator
Jan 30, 2014 at 7:43 AM
Hi Grant,

I'm glad you figured it out.

Maybe you could write a blog post or something that would help people coming from your perspective?

Regards,
Govert
Coordinator
Jan 30, 2014 at 8:16 AM
Hi Grant,

I also gave a bit more RTD information in the discussion on the Google group: https://groups.google.com/forum/#!topic/exceldna/gtW1MWSKxIk

Regards,
Govert
Jan 30, 2014 at 3:38 PM
I think a blog post would be useful. I'll try to come back to that.

A somewhat related question about standard practice: If I had multiple RTD functions to support, would it be standard practice to create a new ExcelRtdServer-derived class for each of them?
Coordinator
Jan 30, 2014 at 4:52 PM
Hi Grant,

Starting a new ExcelRtdServer instance is fairly heavy-weight (compared to adding a single topic). So you'd typically try not to have many RTD server instances. If you are managing some back-end resource (a link to a data source) or opening some communication channel, then you'd probably make a single RTD server for all communication of a particular type, and then clean up any resources when the server shuts down. Many invidual topics (wrapped in one or more UDF functions) could all share a server.

So no - many UDF functions can share a single server, but it makes sense for the server to be some kind of resource management unit.

-Govert