I think that the topic title says almost all about it, but I'll try to be more specific: I have a tomcatservlet which prints out a bunch of .doc files (which are created using JasperReports if this is important) and I need to take those files and put them all in a single file.
Googling around I found this "POI" project which seems to enable Java programmers to be able to manipulate Microsoft Office files (and so also .doc file) using their API, which I downloaded the last version. But I'm not really sure about how actually do this.
Here is what I was thinking to do, from a very high-level point of view:
- create an empty HWPF document
- read the first .doc file into another HWPF document
- copy the content from the last created document to the empty one
- read the second .doc file
- and so on...
Can any of you please help me understand how to implement this? Thank you very much in advance.
Basically my conclusion is that you cannot 'really append' one word document to another using POI.
The best you could do is extract the text and text format and append it to another document. This will work only in case of really simple work documents.
Uhm, that doesn't sound good for me. The documents I need to merge together are all full of tables, images, and also uses different styles.
I was hoping to find a way to do this in Java 'cause if there is one, then the company for which I work wouldn't need to completely rewrite the reporting utility of our software (which is based on tomcat and Java servlets).
posted 10 years ago
Another approach might be to use OpenOffice in server mode. It has a Java API that could be used to open the first file, and then insert all other files at the end successively.
posted 10 years ago
That could be an idea, but since this "merging" solution will need to get installed on our customers computers (because it would obviously be shipped in bundle with our software, a web-based AMP application), I do not think they'd accept to have an openoffice server running on their computers. And this would also require major modifications of our software, that would not be really cost-effective
Let's get him boys! We'll make him read this tiny ad!