Web Development

General discussion


Generate Dynamic Word Content?

By jeff ·
I'm using Cold Fusion 4.5 on a windows-based web server, and I want to generate Microsoft Word documents dynamically. Any ideas? Are there any tools to do this so I don't have to learn how Microsoft Word format works?

Jeff Harris

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Install Perl

by Medium In reply to Generate Dynamic Word Con ...

I had a similar problem that was solved by Perl - and the RTF::Writer component. The RTF spec. is on the MS site and it was easy to implement once you get the hang of it.

In the end you'll have RTF files that are readable by just about any word processor on the market.

Collapse -


by phil_perkins_1 In reply to Generate Dynamic Word Con ...

If you happen to be using MS Word 2000 or XP, you can generate your content in XML. MS Office 2000 and XP support XML for content. You can create a generic document and "save as a web page" to get the basic XML. The XML will appear as long HTML encoded string inside an attribute value in the saved HTML file. You can easily decode this text by saving it to another HTML file and opening it in any browser. Within the browser, you'll see the decoded text. You can copy that and paste it in Notepad. The only other thing that you'll have to do is change the MIME type of the HTTP server to MS Word document:

"Content-type: application/vnd.ms-word"

And add another header:
"Content-disposition: inline;filename=yourdocument.doc"

Of course, you don't have to change the document to HTML as MS Word 97 and above all have the ability to render HTML. But this is only if you are generating simple documents.

I've got an example of generating dynamic Excel documents at http://www.geocities.com/phil_perkins_1/DSSExample.zip

Related Discussions

Related Forums