Multiple Cells Update using RTD Server

811 views
Skip to first unread message

Manoj Aggarwal

unread,
Jun 23, 2015, 6:37:25 AM6/23/15
to exce...@googlegroups.com
Hi All,

I want my RTD server to update multiple cells from my data object. This is like, I have data object with properties - Last Price, Current Price , %Change etc. Similar to these properties, I have three columns in my Excel. I want my RTD to update all my cells with one call . Is it possible ?


Govert van Drimmelen

unread,
Jun 23, 2015, 6:43:51 AM6/23/15
to exce...@googlegroups.com

If you have a wrapper function for the RTD, the wrapper can return an array which you use in an array formula.

In particular the IExcelObservable mechanism should work fine for array formulas.

 

Another pattern is to have one cell return a ‘handle’ of some sort which you update with the RTD. Then have another function that just takes the handle and a property string, then looks up the array or object behind the handle internally, and returns the respective property. The lookup function won’t be an RTD function, but will update every time the handle updates due to the dependency in the formula.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Manoj Aggarwal

unread,
Jun 23, 2015, 10:28:57 AM6/23/15
to exce...@googlegroups.com
Hi Govert,

Thanks for the suggestion.

For the time being, I have wrapped my return value in array formula.

For someone like me, who is very new to Excel and DNA -:

MY UDF -:

 public static object SubscribePriceRtd(int uic,string assetType)
       
{
         
return   XlCall.Excel(XlCall.xlfEvaluate,ParseData(uic,assetType));
           
       
}
       
public static object ParseData(int uic,string assetType)
       
{
           
return (XlCall.RTD("Excel.RTDServers.PriceSubscriptionRtd", null,
                   
new[] {uic.ToString(CultureInfo.InvariantCulture), assetType}));
           
 
       
}

MY RTD Server -:

namespace Excel.RTDServers
{
   
public class PriceSubscriptionRtd : ExcelRtdServer
   
{
       
private Timer timer;
       
public PriceSubscriptionRtd()
       
{
           timer
=new Timer();
           timer
.Interval = 9000;
           timer
.Elapsed += timer_Elapsed;
           timer
.Start();
       
}
       
void timer_Elapsed(object sender, ElapsedEventArgs e)
       
{
           
var ran = new Random();
           
var first = ran.Next(2000);
           
var second = ran.Next(1000);
           
var value = "{" + first + "," + second + "}";    
           
UpdateTopic(value);
       
}
       
private  readonly List<Topic> topics = new List<Topic>();
       
protected override object ConnectData(Topic topic, IList<string> topicInfo, ref bool newValues)
       
{
           topics
.Add(topic);  
           
return "{0,0}";
       
}
       
protected override void DisconnectData(Topic topic)
       
{
           topics
.Remove(topic);
           
base.DisconnectData(topic);
       
}
       
public  void UpdateTopic(string value)
       
{
           
foreach (var topic in topics)
           
{
               topic
.UpdateValue(value);
           
}
       
}
   
   
}
}


Select 2 cells in Excel, write    = SubscribePriceRtd (1,"blah-blah")  and hit  Ctrl + Shift + Enter .
You will see data updating in 2 cells.

Larry Lin

unread,
Jul 7, 2015, 10:42:11 AM7/7/15
to exce...@googlegroups.com
Manoj,
I use array formula with RTD server, I can not get DiscinnectData event when change the formula parameter as a new request.

Do you have some issue?

Manoj Aggarwal

unread,
Jul 17, 2015, 9:23:43 AM7/17/15
to exce...@googlegroups.com
Hi Larry,

No disconnect is not working.. Did you find solution ?


On Tuesday, June 23, 2015 at 4:07:25 PM UTC+5:30, Manoj Aggarwal wrote:
Reply all
Reply to author
Forward
0 new messages