Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement an Excel UDF that can call web methods asynchronously

Initially, I implemented an UDF that would call web methods Synchronously, but had quite a lot of troubles with that, especially when I tried to request huge amount of data -- in short, Excel would hang and freeze until all data was retrieved, which severely jeopardizes the user experience.

I am guessing consuming web service synchronously is the real killer here. So I wonder if there is any way that I can do it Asynchronously? Can anyone give me some pointers? Any tools or platform is more preferred? (Personally I still prefer using C#)

like image 897
woodykiddy Avatar asked Sep 19 '11 09:09

woodykiddy


Video Answer


1 Answers

RTD would work. You have to implement the IRtdServer interface. When your add-in is started, Excel gives you a function pointer. For each cell you will be given an "excel id" and a list of arguments. Send your async web request. When the response arrives, you call the notfiy function that Excel gave you. When Excel is ready it will call your GetData method to actually get the data.

See How do I create a real-time Excel automation add-in in C# using RtdServer? for an example of how to do this in C#.

Once you understand how RTD works, Excel-DNA does a nice job of abstracting away the COM plumbing...highly recommended.

like image 185
Frank Avatar answered Nov 15 '22 05:11

Frank