Re: MS word document generator
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: MS word document generator

From: Grant Edwards <grante@visi.com>
Date: Wed Mar 15 2006 - 16:11:44 CET

On 2006-03-15, Raja Raman Sundararajan <ram0812@hotmail.com> wrote:

> Is there any nice library to generate word documents using Python.

I find the following works well for me:

f = open("file.doc")
f.write("Hello there.\n")
f.write("How are you?\n")
f.close()

> As of today I am generating a HTML document and then open it
> with MS Word. But the problem is that I am not able to control
> the pages in the document and as a result of it the output
> looks terrible.

If you want fancier formatting that available in my example
code, I'd look for a library to generate RTF. Something like
this perhaps (I haven't tried it yet):

   http://pyrtf.sourceforge.net/

RTF is far more portable that whatever ".doc" format-du-jour
happens to be in vogue in Redmond.
   
> I have been using reportlab's platypus to generate PDF
> documents. Its a nice application which allows controlling
> segments of the pages programatically.
>
> I was wondering if there was any library as reportlab to
> generate word documents.

-- 
Grant Edwards                   grante             Yow!  ... I have read the
                                  at               INSTRUCTIONS...
                               visi.com            
Received on Sun Apr 30 11:54:40 2006