The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Dynamic word document generation

In Server application based on business rules, I would like to dynamically generate word documents. Content and layout would be fully customized.How do I go about doing it?

I could use XML/XSLT solution but then xml file has to be created every time word document is generated and over time it would be waste of disk space.

Based upon final sql query results, could I just use xslt document (with out xml document) and generate a customized word document?

Please help and thank you in advance
Sunday, January 29, 2006
Use the COM interface exposed by Word. Yo can use it from .NET by simply adding a reference to it.
smalltalk Send private email
Monday, January 30, 2006
You do *not* want to use automation of Word in a server application.

I've used this component and thought it was awesome:

A Word object model implementation directly in managed code - safe to use in a server application.
arethuza Send private email
Monday, January 30, 2006
I asked this same question over at Experts Exchange last year.  Basically you set bookmarks in the Word doc, then programatially replace the bookmarks with text.

Like this:

oWord.Application.ActiveDocument.Bookmarks.Item("BookmarkName").Range.Text = "Text I want to go there."
Deane Send private email
Monday, January 30, 2006
"You do *not* want to use automation of Word in a server application."

This is very true.  I used the code above in VBA from within other desktop apps.

Microsoft has a whole support page devoted to dissuading you from instantiating Word on a "unmanned" machine.;EN-US;q257757

Word really needs to run in the context of a user to load a bunch of user profiles and such.  If it pops a dialog box while doing this, and there's no one there to close it, then you're fairly boned.
Deane Send private email
Monday, January 30, 2006
generate an .rtf file. the low end solution is create a template and replace some text in it, with simple string functions.

and yes, do not use word/excel in server app, it can popup dialogs for whatever reason, which you won't be able to handle (no desktop).

Monday, January 30, 2006
The Aspose guys have even more information on why not to use Word automation from a server application:

Of course, they are trying to get you to buy their product.
arethuza Send private email
Monday, January 30, 2006
I interviewed once for a company called SoftArtisans that makes a product for this.  I've not used it but it looks good:
Jacob Send private email
Tuesday, January 31, 2006

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz