Have a look at the Range class and you will see a method called replaceText(). This method can be used to replace one piece of text - called the placeholder - with another - called the replacement text much in the manner of a mail merge I guess. If you look closely at the javadoc, Paragraph is a subclass of Range so the method should be available on your object 'p' meaning the changes you will have to make are (hopefully) very simple.
I am far from being an expert so I do not know how you can use it to search through a document to replace numerous occurrences of a placeholder but suspect there is a way because it is possible to define the offset - the point within the document at which the method begins searching for the text to replace. --- On Fri, 12/5/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: From: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Subject: POI - HWPFDocument To: [email protected] Date: Friday, December 5, 2008, 12:52 AM Hallo everyboby. I have benn looking for the last days in internet trying to find a solution for my problem, and I found nothing that could help me...so I am asking you help... The problem: I store in oracle table field (BLOB) a word document.This document is a template whose content is text and also few fields that I'm trying to fill up at runtime using HWPFDocument...but I don't find the way. What I want to do is at field with name "name" put e.g. "Myname", to address put "MyAddress" and so on..... Here few code lines and what it prints Range r = wordDocument.getRange(); for (int x = 0; x < r.numSections(); x++){ Section s = r.getSection(x); for (int y = 0; y < s.numParagraphs(); y++){ Paragraph p = s.getParagraph(y); for (int z = 0; z < p.numCharacterRuns(); z++){ CharacterRun run = p.getCharacterRun(z); //character run text String text = run.text(); System.out.println(text); } } } "name" John Smith "address" 99 North Road "postCode" X1 2YZ "city" London "date" Tuesday, 8 August 2006 Dear "name" John Smith .......... Hope my english is understandable... Thanks in advance. Gilio Simione P.S. Here is the template stores in the database. Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede contener informacion confidencial, siendo para uso exclusivo del destinatario, quedando prohibida su divulgacion copia o distribucion a terceros sin la autorizacion expresa del remitente. Si Vd. ha recibido este mensaje erroneamente, se ruega lo notifique al remitente y proceda a su borrado. Gracias por su colaboracion. This message (including any attachments) may contain confidential information. It is intended for use by the recipient only. Any dissemination, copying or distribution to third parties without the express consent of the sender is strictly prohibited. If you have received this message in error, please delete it immediately and notify the sender. Thank you for your collaboration. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
