|
Val's Blog
Lots of stuff for Web 2.0 freaks and Java addicts
|
|
|
Albert Einstein: "Intellectuals solve problems: geniuses prevent them." |
[ Login ] |
|
Ever needed to generate Word documents from your Java applications? There are only a few tools that allow you to do that. The Apache POI team has developed an API for manipulating Excel files (org.apache.poi.hssf packages) and is currently developing one for Word files also (org.apache.poi.hwpf packages). However, the latter is still in early beta stages and is not bundled with the 2.0 release, so you have to go into CVS and get the files by yourself. If this suffices, then you are good to go. Otherwise I can propose another solution. A German software company, called Müller & Stein Software, proposes on its website a free component (yes, as in "free" beer) that you can call directly from your Java application to generate any kind of Word files. The downside is that it won't let you read the Word file, though. You're gonna have to use the POI HWPF API if you need that functionality. The way the whole thing works is incredibly easy. In the bundle, you will find three key files:
All you have to do is to define bookmarks (Insert/Bookmark) in the template Word file and give them a name. This name will let you identify what goes where when you generate the Word file. Then, from you Java application, you can write code like:
Let me explain a little further what this code does:
Before calling
As you can see this Java2Word component is very simple, yet very powerful. Play around with it and you won't be disappointed. The installation is straightforward and the driver is very fast. In my case, I have to generate 50 pages Word files, and the whole thing takes like four to five seconds.
TrackBacks[0]
Comments[53]
Posted by val on October 16, 2004 8:52:08 AM CEST
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content © Val | Powered by Pebble 1.9.1 |