Home » excel » c# – What is the appropriate technology to pull data to into excel spreadsheet via a formula from a .NET source?

c# – What is the appropriate technology to pull data to into excel spreadsheet via a formula from a .NET source?

Posted by: admin March 9, 2020 Leave a comment

Questions:

I would like to be able to allow a user to enter a custom formula in a cell in Excel which will subscribe to data provided by an external .NET application. For example, the user might enter…

=getCurrentValue("ABC")

There is an external .NET (C#) application that is determining the value of “ABC” every minute.

The cell should display the initial value of “ABC” from the external application and update when the external application sends a new value.

In the past I think the external application would be a DDE server and the formula would be a DDE client formula but DDE is apparently dead. What is the “correct” technology to use to do this?

Note that the spreadsheet needs to pull the data via a formula. The information is not going into a fixed template excel file but into any spreadsheet into which the user enters a formula.

Thanks,

John

How to&Answers:

Excel RTD (Real Time Data) is the replacement for DDE. It allows you to push values to a cell whenever updates are available. If the process providing the updates is an external application, setting up a WCF channel between the RTD server and the external app should allow you to feed real-time updates into Excel.

Here are some links:

Answer:

You can communicate with Excel sheets through the Excel Api:

new Microsoft.Office.Interop.Excel.Application();