poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mapleleafs89 <maple_leaf...@hotmail.com>
Subject Range Replace Text Word Document with MergeFields
Date Sun, 16 Jun 2013 04:47:13 GMT
Hi I am trying to do a simple replaceText call, I have mergefields in my .doc
file that I am trying to insert data into. It does it successfully but the
output is not what is expected. The word MERGEFIELD and the name of the
given mergefield are both printed into the document in addition with the
text I inserted myself.

Is there anyway around this or is it a limitation of the Apache POI for

See code below:

       String inputFilename = "C:\\a.doc"; 

       String outputFilename = "C:\\Users\\Me\\Desktop\\b.doc";
       POIFSFileSystem fs = null;
       FileInputStream fis = new FileInputStream(inputFilename);
       fs = new POIFSFileSystem(fis);

       HWPFDocument doc = new HWPFDocument(fs);

       Range range = doc.getRange();

       range.replaceText("This", "That");

       FileOutputStream fos = new FileOutputStream(outputFilename);


View this message in context: http://apache-poi.1045710.n5.nabble.com/Range-Replace-Text-Word-Document-with-MergeFields-tp5713016.html
Sent from the POI - User mailing list archive at Nabble.com.

To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

View raw message