I think the easiest way to do this (for more recent versions of Word/Excel,
I think 2002+) is to:
1) save a document or spreadsheet as XML
2) rename the xml file with the appropriate .doc or .xls extension
3) use the renamed xml file as a Kid/Genshi template
4) make sure to set the MIME type on the HTTP response correctly (this is
probably the trickiest part, as there are a number of possible MIME types
for these files)
The output should then appear to the user to be a normal Word/Excel file.
I've used this technique successfully with various PHP templating languages,
so it should work in Python with no problem, though to be honest, I haven't
tried it with MS Office. I have done similar things with OpenOffice and
Python using a helper module that I've developed. If enough people are
interested, I could clean up and release my helper module. Let me know if
there's any interest.
NOTE: Office 2007 uses a new xml-based format, which is totally different
from the Office 2002/2003 format. I'm not sure what kind of
interactions/incompatibilities this will cause.
Good luck!
Kevin Horn
On 7/16/07, fumanchu <[EMAIL PROTECTED]> wrote:
>
>
> On Jul 16, 4:20 am, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> > On Monday 16 July 2007 02:12:31 iain duncan wrote:
> > > I would like to add the option for my client to download ready to
> print
> > > invoices as one big doc, and am wondering what people would use to do
> > > that. I have heard good things about the Apache POI project, but it
> > > seems to have only Ruby bindings. Anyone have any suggestions of what
> > > they like?
> >
> > For Excel you can use CSV and it will open it. If you really want an
> Excel
> > spreadsheet there are some Python packages out there (PyExcelerator,
> IIRC, is
> > one of them). You'll need some of these packages if you're willing to
> create
> > formulas and graphics.
>
> If your users have modern Excel (2002+?) and Internet Explorer, you
> can deliver Excel docs in the browser just by outputting an HTML
> table. Set the following headers:
>
> h = cherrypy.response.headers
> h['Content-Type'] = "application/vnd.ms-excel;charset=utf-8"
> h["Content-Disposition"] = ("inline; filename=%s.xls" % fname)
>
> ...and replace in-cell br tags with "<br style='mso-data-placement:
> same-cell' />". You can include tags like b, i, a, and img, and
> they'll all transfer nicely.
>
>
> Robert Brewer
> System Architect
> Amor Ministries
> [EMAIL PROTECTED]
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---