views:

2183

answers:

4

I have a ms-word document (MS-Office 2003; non-xml). Within this document there is a string associated with a bookmark. Furthermore, the word document contains word-macros. My goal is to read the document with java, replace the string associated with the bookmark, and save the document back to word format.

My first approach was using Apache POI HWPF:

HWPFDocument doc = new HWPFDocument(new FileInputStream("Test.doc"));
doc.write(new FileOutputStream("Test_generated.doc"));

The problem with this solution is that the generated file does not contain the macro anymore (File size of the original document: 32k; file size of the generated document 19k).

Does anybody now if it's possible to retain all the original info using POI/HWPF?

A: 

I have the same problem. But it seems there is no solution to this. No one is developing anything to work with Microsoft files through java.

PKP
A: 

never found a solution. The customer had to pay an Aspose-license (expensive) or refrain from using macros.

A: 

HI, I am trying to read a word doc that contains a table using POI. The requirement is to create rows in a Database Table with the information extracted from the table rows in the word document. For example, my word doc has a table like:

Heading Description Heading1 summary related to heading1 Heading2 summary related to heading2 .....

And my database contains a table named SUMMARY with the following columns:

ID DateAdded FileName Heading1 Heading2 ..... (as many heading columns as the number of rows in my word document table)

So I need to read the document using java, get the description text for each heading and then store that as a BLOB in the respective table column. I have tried using POI for this requirement. I am able to read the table rows and extract the text in each cell. But the data retrieved from cells using POI does not contain bullets or other formatting even though my original doc has bullets. All I am getting back is plain text. So is it true that I can not read the text along with bullets by using POI API? That is what I understood from the reply you posted above..Please let me know ... Thank you very much Jaikar

Jaikar
A: 

Hi to all,

Is there any chance to convert an .doc and .docx files to html pages using Java and POI jar?

Jetti