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#)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With