Generating Word Docs (PHP)

3 views
Skip to first unread message

dbowling

unread,
Jun 1, 2009, 4:28:51 PM6/1/09
to Missoula Web Discussion Group
I've recently ran into a requirement where I have to be able to
generate word documents. Does anyone have a hint as to an easy way to
do that?

What I've seen so far is to toss an HTML page with inline styles and
change the header to be application/ms-word with a file extension
of .doc. Anyone know of anything easier or better?

Dan

Tim Greiser

unread,
Jun 1, 2009, 4:35:49 PM6/1/09
to missoula-web-d...@googlegroups.com
Well, it's not exactly word documents, but RTF is a more open format that can be opened/edited in Word.  I don't own the code (written for an old employer), but it was fairly easy to write an RTF generating library in PHP.  I picked up the O'Reilly pocket guide and it covered everything I needed to know regarding the format.

http://oreilly.com/catalog/9780596004750/

Tim.

dbowling

unread,
Jun 1, 2009, 6:34:39 PM6/1/09
to Missoula Web Discussion Group
Thanks Tim,

I'll keep that in my back pocket. I have a feeling that I'll need more
formatting than RTF allows.

Dan


On Jun 1, 2:35 pm, Tim Greiser <tgrei...@gmail.com> wrote:

Cliff

unread,
Jun 1, 2009, 6:54:22 PM6/1/09
to missoula-web-d...@googlegroups.com
What verion of word are you targeting?

Dan Bowling

unread,
Jun 2, 2009, 12:49:03 AM6/2/09
to missoula-web-d...@googlegroups.com
Whatever is easier. I doubt they are going to drop compatibility any time soon.

Dan

Cliff

unread,
Jun 2, 2009, 8:11:49 AM6/2/09
to missoula-web-d...@googlegroups.com
Backwards compatibility probably won't be going anywhere, but the same may not be true of cross-compatibility and forward compatibility. Knowing which version of Word your client plans on using still helps you know what *other* formats it can read.
 
What I was actually thinking was ODF.  It'd solve your problem with RTF not allowing for enough formatting and since it is an open standard with a fair amount of industry support, there are open source libraries out there with APIs that PHP can easily hook into.  ODF support was not added to MS Word until 2007 SP2 though.  No RTM support and no support in previous versions.  So it may not be suitable at all.
 
OO-XML is another possibility.  Office 2007 RTM supports it and there are compatibility packs from MS to add OO-XML to Office 2003, but 2000 and earlier would be in the dark.
 
Just a couple of thoughts,
 
-Cliff
Reply all
Reply to author
Forward
0 new messages