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
HWPF.
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);
doc.write(fos);
fis.close();
fos.close();
--
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: [email protected]
For additional commands, e-mail: [email protected]