File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes creating word document from java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "creating word document from java application" Watch "creating word document from java application" New topic

creating word document from java application

jamie ong

Joined: Nov 05, 2001
Posts: 24
my java application requires to create a record catalog in ms word document. is there any possible way to do so?
many thanks!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Off the top of my head, two means come to mind:
1) Use JNI to interact with C++ code that uses COM to interact with Word. (GA!)
2) Emit RTF which Word will read in just fine but which is a lot easier to generate.
Not really my area of expertise so others may have better ideas.

[Asking smart questions] [About Bear] [Books by Bear]
Jorge Phillips
Ranch Hand

Joined: Jun 03, 2001
Posts: 43
How about just writing out a text file (possibly with a .txt extension) and reading it into Word. Word should convert the file automatically. You can then save the file as a .doc file and then apply any formatting you need using macros, etc. to expedite the process.
If this is a one shot deal, I would favor this approach.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I would definitely prefer to use Java to generate RTF documents than Word documents. Word is very proprietary and this year's Word document format is not next year's Word document format is not last year's Word document format.
I have not yet run across an API that just outputs Word documents from Java. I know the group working on the POI project over at Jakarta are developing such an API to generate Word '97 documents. I'm not sure how far along they are. Take a look at their project site for more information.
Mueller Und Stein offer a free Java Bean to control Microsoft Word.
Otherwise, perhaps there is an indirect path through XML to get from Java to Word (and perhaps back again).
Good Luck.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: creating word document from java application
jQuery in Action, 3rd edition