Return-Path: Delivered-To: apmail-poi-user-archive@www.apache.org Received: (qmail 16470 invoked from network); 5 Dec 2008 13:09:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Dec 2008 13:09:56 -0000 Received: (qmail 48485 invoked by uid 500); 5 Dec 2008 13:10:06 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 48470 invoked by uid 500); 5 Dec 2008 13:10:05 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Received: (qmail 48459 invoked by uid 99); 5 Dec 2008 13:10:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 05:10:05 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [209.191.85.21] (HELO web36604.mail.mud.yahoo.com) (209.191.85.21) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 05 Dec 2008 13:08:35 +0000 Received: (qmail 46709 invoked by uid 60001); 5 Dec 2008 13:09:22 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=bQWNIE8xEU4ms6ebdaweUL4NwLbXyB/U94JOyzn0FpYdCrtx+LBmaIMDMd0dyotUKKAwkLPu7nLj0aUpCisz3VVlVuuK1/6CPoCsO9Lzr8dq666wHMjwJXYa6vHMSfUyBQ65GqYv0oyFPXk5k9lGFrwivANoj5BVPrkeCJMaIiY=; X-YMail-OSG: SNXxY3IVM1kczVWk8Jlp87Ty9ZJw5pdfqlivVo6EGUi1Ce7AuHBfJX5Jz3gPCvj5G_rvxH0bkTjcxV1Zd5hTYKM5YQ4YRJtWg9J.MB.BkfaoIE6FHG7SJ33on2YToeRCI6kWhuTQ4jKuO6in7vdWHHaQVrwxb_zEsUYIRdysXOb3Qhq1J2gjGhcn22gB Received: from [88.107.226.91] by web36604.mail.mud.yahoo.com via HTTP; Fri, 05 Dec 2008 05:09:22 PST X-Mailer: YahooMailWebService/0.7.260.1 Date: Fri, 5 Dec 2008 05:09:22 -0800 (PST) From: Anthony Andrews Reply-To: pythonaddict@yahoo.com Subject: Re: POI - HWPFDocument To: POI Users List In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1438599642-1228482562=:46597" Message-ID: <690091.46597.qm@web36604.mail.mud.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org --0-1438599642-1228482562=:46597 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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 place= holder - 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 sub= class 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 su= spect there is a way because it is possible to define the offset - the poin= t within the document at which the method begins searching for the text to = replace. --- On Fri, 12/5/08, gillio_simione@ieci.es wrote: From: gillio_simione@ieci.es Subject: POI - HWPFDocument To: user@poi.apache.org 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...=20 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 =A0I'm trying to fill up at runtime using HWPFDocument...bu= t 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 =3D wordDocument.getRange(); =A0 =A0 =A0 =A0 =A0 for (int x =3D 0; x < r.numSections(); x++){ =A0 =A0 =A0 =A0 =A0 =A0 =A0 Section s =3D r.getSection(x); =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (int y =3D 0; y < s.numParagraphs(); y++){ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Paragraph p =3D s.getParagraph(y); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (int z =3D 0; z < p.numCharacterRuns(); z++){ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CharacterRun run =3D p.getCharacterRun(z); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //character run text =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 String text =3D run.text(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 System.out.println(text); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } =A0 =A0 =A0 =A0 =A0 =A0 =A0 } =A0 =A0 =A0 } "name" John Smith "address" 99 North Road "postCode" X1 2YZ =A0 "city" London "date" Tuesday, 8 August 2006 Dear=20 "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=20 destinatario, quedando prohibida su divulgacion copia o distribucion a=20 terceros sin la autorizacion expresa del remitente. Si Vd. ha recibido=20 este mensaje erroneamente, se ruega lo notifique al remitente y=20 proceda a su borrado. Gracias por su colaboracion. This message (including any attachments) may contain confidential=20 information. It is intended for use by the recipient only. Any=20 dissemination, copying or distribution to third parties without the=20 express consent of the sender is strictly prohibited. If you have=20 received this message in error, please delete it immediately and=20 notify the sender.=20 Thank you for your collaboration. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org=0A=0A=0A --0-1438599642-1228482562=:46597--