Integrate a GUI in a excel sheed

Alexander Eisenhuth stacom at stacom-software.de
Wed Feb 19 03:15:21 EST 2003


Brian Kelley schrieb:
> I have actually done this and it wasn't very easy.  The basic steps that 
>  I took were as follows.
> 
> Excel -->  Visual Basic Wrapper --> Python COM Server --> os.spawn 
> Remote wxPython GUI application
> 
> Spawning the GUI doesn't block the COM server which is essential. 
> Otherwise EXCEL hangs very hard.
> 
> So getting the data into the remote GUI was fairly easy.  The hard part 
> was letting the COM server "know" where the GUI app was located so it 
> could be launched from a system call.  I used the windows registry for 
> this purpose and my had installer write the location of the gui app.
> 
> Now the hard part, what about getting data *back* into excel?
> 
> When the GUI is called it is sent the Active workbook and worksheet 
> numbers along with any relavant cell information and data.  If the 
> remote GUI has the workbook and worksheet it can write any desired 
> information back to excel.
> 
>  >>> ms = client.Dispatch("Excel.Application")
>  >>> book = ms.Workbooks(1) # appropriate workbook #
>  >>> book.Worksheets(1)     # appropriate sheet #
>  >>> sheet = book.Worksheets(1)
>  >>> sheet.Cells(1,1).Value = "foo"
> 
> What are the problems with this approach?  wxPython startup times are 
> abyssmal and the overhead is huge about 10MB.  The COM server doesn't 
> talk to the GUI so EXCEL really can't inspect any GUI states.  You could 
> fix this by letting the COM Object query the GUI through a socket or 
> file based interface
> 
> I think that this approach would be pretty good for your application. 
> You aren't really "embedding" wxPython into excel, merely launching it 
> with a mechanism for excel automation.
> 
> I actually just submitted a proposal for a Python tutorial for this at 
> PyCON so I'm delighted to see that someone may actually use it :)  Even 
> if I don't do the tutorial I will be writing up the whole processes. 
> Feel free to ask any more questions if you are interested.  I am 
> actually using this approach in a commercial product (which means that I 
> feel relatively confident that it is stable)

Thanks for your project description. I thought it "should" be possible in the way you did it. I think our applications are quite similar.

I'm working on the approach with myApplication-COM-server and IP commun. to a GUI appl. After the user has finished his configuration in the GUI appl. i get back with the data into excel to show him his entered data, instead of a graph-widget. 

What I'm wondering is, if I startup a python app, and create a excel-COM-obj. a new process is launched, but when i create a python-COM-obj. in excel it is dynamically linked in the excel process.

In the prog. on python book (p. 197) this is covered with "LocalServer" and "InProc" server, but i didn't have the time yet to work it out. Have you ever thought about that for your appl.?

Cheers
Alexander





More information about the Python-list mailing list