tags:

views:

46

answers:

2

I have an application that I want to link to excel. I have no preference which control is used as long as I can copy the data or control, and paste link into excel. When the data changes in my application, I want the cell to change in excel.

I have a client that claims it is possible and he has seen it, but has no proof and may be confused.

I have searched the internet and have come up with a number of half-solutions, and people who want the opposite of what I want. Does anyone know the full solution?

+1  A: 

I think you're looking for the IDataObject COM interface.

If you expose your data as an OLE object, you can use IDataObject::DAdvise to notify Excel when the data in your application is changing.

This takes some effort, as you have to implement the IDataObject interface (along with a few others) to allow Excel to properly display and host the information you are exposing.

If this is what you're after, here are some links you may find helpful:

http://winapi.freetechsecrets.com/ole/OLEIDataObjectDAdvise.htm

http://www.catch22.net/tuts/dragdrop/1 (mostly deals with Drag/Drop)

http://www.catch22.net/tuts/dragdrop/2 (mostly deals with Drag/Drop)

http://www.catch22.net/tuts/dragdrop/3 (mostly deals with Drag/Drop)

http://us.generation-nt.com/answer/support-iadvisesink-word-excel-powerpoint-help-26654252.html

http://www.tenouk.com/visualcplusmfc/mfcsupp/ioleobject.html

LBushkin
A: 

Another option would be to develop an Excel plug-in using VSTO. The difficult part of this architecture would be that you have to implement your own IPC between the source application and the plug in. However, I'd choose this over IDataObject (DDE Emulation) based on prior experience with DDE.

The advantage of the IDataObject approach is that a typical old school Excel power user will be comfortable with it; and it doesn't require any plug-ins to function. If the act of dragging the control and dropping onto Excel is an important part of the scenario, then it's probably worth implementing a COM server. However, if your client isn't familiar with DDE and just wants to have Excel updated dynamically, that's probably not worth the effort.

Paul Keister