[Zope] Integrating Zope with Excel.

Joe Goldthwaite joe at goldthwaites.com
Wed Aug 25 18:24:47 EDT 2004


Thanks for the reply J.F.  I can use all the input I cat get.

Although I might run into problems with re-entrancy when this goes into
production, I don't think that's the case here.  I'm the only one using the
machine and I'm not submitting concurrent requests.   I also thought Zope
was multi-threaded so it has to finish a request before it can start another
one.  I could be wrong on that though.

Joe Goldthwaite


-----Original Message-----
From: Jean-Francois.Doyon at CCRS.NRCan.gc.ca
[mailto:Jean-Francois.Doyon at CCRS.NRCan.gc.ca]
Sent: Wednesday, August 25, 2004 3:06 PM
To: joe at goldthwaites.com; zope at zope.org
Subject: RE: [Zope] Integrating Zope with Excel.


I don't know much of anything about coding on windows, but I had looked at
doing something smiliar once ... To convert PPT's on demand to HTML in my
case, but I looked at using Python's COM features to do it (Regular Python +
win32all, not ActiveState's).

One thing that stopped me dead in my tracks was many comments form Microsoft
that all the Office related COM objects are NOT re-entrant.  Therefore
Excel.Application can only exist once and so on, and you have to take care
with such issues ... This is why nonbody's written an MS Office based Web
Service :)  You're not really using it as a web service, but the same
concecpt applies I think?

Basically, I'd look at object re-entrancy and concurency issues on the MS
Office side.

I ended up never needing mine, but I think I'd had it down to the fact that
the best was to have the Application instance running and use Document
instances to do the work ... Thing is I really didn't want to have
PowerPoint instanciated permanently on the server.

Anyways, just some thoughts, though I'm not sure they're of any help :)
J.F.

-----Original Message-----
From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
Joe Goldthwaite
Sent: August 25, 2004 5:40 PM
To: zope at zope.org
Subject: [Zope] Integrating Zope with Excel.


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


_______________________________________________
Zope maillist  -  Zope at zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )



More information about the Zope mailing list