tags:

views:

243

answers:

8

I would like to be able to link some data from a custom application to a cell in Excel.

What tech would you use to do that? I'm primarily a Unix-developer, and don't know win32 technologies in depth. But as far as I understand DDE would be the easiest, even though it is very old tech.

Being able to use it with other office suites such as OpenOffice would be a big bonus.

A: 

Easiest way to link to a cell value is via the .net data providers in Visual Studio 2008. Here is a link to some of the more common methods. Link

It's going to be difficult to try and make this available to open office as the data providers aren't the same.

Dayton Brown
A: 

I'd recommend using Java/JVM and its Apache POI library.

It can read and write Excel files and it's pure cross-platform java. It's pretty reliable in practice.

http://poi.apache.org/

alamar
I don't want to read/write excel-files: I want to get a connection to my application, as a data provider.
Jonatan
Oh, that would be OLE.
alamar
+1  A: 

In .NET I would use the COM libraries for Excel. You can use Workbook, Worksheet and Range objects to address specific cells in specific worksheets and workbooks. These work well from .NET (especially VB.NET).

John M Gant
A: 

Jonatan,

If the source application stores the data in a database, or a text file, it will be possible to use excels' build in data functions to retrieve it. Otherwise I would agree with Dayton on the integration with VS2008. You can use VS2005, however it will require you to install VSTO.

Regarding DDE - aside of being almost obsolete, there are problems while using different versions of Excel and different languages, which will require you to use different keywords for the same operation

Danny Shumer
+1  A: 

The COM interface is really easy. You start by recording a macro, and do what you intend to do. After that translate the generated code into the programming language of your choice.

GvS
+1  A: 

What does it mean "link data from a custom app to a cell in Excel"?

Do you want the Excel sheet to display data that is generated by some external app?

If that is the case there are a number of options. The Excel data provider is one way to go. This works if you have lots of data you'd like to load. For just one cell, it may be overkill.

If the external data is accessible via a network interface (let's say, HTTP), then you can write some Excel macro code to consume it. You could use the ServerXmlHttp object to consume it, from within Excel. Some guidance on that is HERE.

Another way to do it is to expose the data via a custom COM object, a re-use construct that is very consumable by Excel. You'd have to write some code to do it, but it's not too complicated. You can write it in .NET, C++, Javascipt, VBScript, PerlScript, ...

Cheeso
A: 

Just to clarify: DDE works with open office. I am a Bloomberg user, and I opened an office 2003 spreadsheet in open office which contained bloomberg links to stock prices updated via DDE, and it works like a charm.

that's good to know!
Jonatan
A: 

All solutions I have seen here have the approach to push the data to excel. Why not give the responsibility of pulling this data to Excel itself? Excel does have the ability to add data through oleDB and ODBC. (at least from the version I know) I can only test that in Office2007, the only version I have on my machines.

All you have to do is add this option to the spreadsheet with the data tab. Pretty simple. That way you also free yourself from the burden to maintain the code in your app to open Excel, run some code to push the code into the cells etc. You could probably record a macro for this and run that when the excel sheet is opened.