[Zope] Integrating Zope with Excel.

Joe Goldthwaite joe at goldthwaites.com
Wed Aug 25 17:40:01 EDT 2004


Hello Again,

I've been working on a Zope application and one of the tasks is to integrate
the web reports with Excel.  I've got some financial reports that the user
can browse through using a web interface.  What I'm trying to do is have a
link on the page that will download the report they're viewing into a local
Excel worksheet.

I decided to use com because I want the worksheet to have colors, print
settings, formatting, etc. I already have working code in VB.  I've looked
into XML and Pyxlwriter but it looks like a new learning curve compared to
just translating my VB com commands into Python.

I'm using Visual Studio .Net 2003 with Active Python as my development
environment.  When I submit the URL that creates the XL worksheet in
development, it works like a top.  In testing, I've generated 50 different
worksheets without any problems.

When I try to run the same code in Zope I have problems. Under Zope, I take
the submitted URL and create a worksheet that I save to a file.  Then I
return a meta command to redirect the browser to the newly created file
which is downloaded to the users computer. The good news is that it works
perfectly - sometimes. Other times I get this error message;

     Module ExcelReport, line 48, in __init__
     Module win32com.client, line 95, in Dispatch
     Module win32com.client.dynamic, line 91, in _GetGoodDispatchAndUserName
     Module win32com.client.dynamic, line 79, in _GetGoodDispatch
     com_error: (-2147221008, 'CoInitialize has not been called.', None,
None)

The error message is coming back from the line; XLApp =
Dispatch("Excel.Application").

The really strange thing is that the error seems to be random.  Sometimes it
works, sometimes it doesn't.  I haven't been able to determine any rhyme or
reason to it.  When I restart Zope, it will work one to as many as 10 times.
Then I'll get the error message.  If I keep trying the same URL, it might
eventually work or I may have to restart Zope to get it working again.

Does anyone have any idea as to what's going on here?


Thanks,

Joe Goldthwaite




More information about the Zope mailing list