Srinivas,
Like I said, I have worked with reading word files, so I would do it sequentially.
For example, create a document, and then use the insertParagraph() method: I think
there is one for before and one for after the current paragraph so if you were
creating it from nothing, you would primarily use insertAfter(Paragraph). The letter
could be all hard-coded in the executable file, and the user inserts the data to be
filled.
Also if you have already created this template that you want to duplicate, you could
use the same idea as creating it from the beginning. I would read through the file
until I saw some marker, then insert the required text. I just wrote this code in the
email, so it is not tested at all:
for (int i=0; i<range.numParagraphs(); i++)
{
Paragraph p=range.getParagraph(i)
for (int j=0; j<p.numCharacterRuns(); j++)
{
CharacterRun CR=p.getCharacterRun(j);
if (CR.text().startsWith("RE:")
{
p.insertAfter(reply-name, CR.getProperties());
}
}
}
Obviously, you will have to do a bit more work than that. But I think what I'm trying
to say is that a word file is sequential. As far as I know you can't jut insert text
in a location on the document, but only a location relative to the rest of the text.
So the date would be getParagrpah(0) because it's the first thing. If you created the
template and are sure you will never change it, then you could use integers for
everything. i.e. getParagraph(10); insert("Address Here"); Where you use the number
10, instead of reading the document to find a marker.
Just a few ideas you might want to try to modify in your own way so that they apply to
your project. I hope they help some.
Tim Forbis
[MEDICAL DATA REMOVED AS PER HIPAA]
Above format is template.I have fill the template at run time with pre-arguments(like
date or name in above XXXXXX formates). I am able to insert the data to word documetn
.But I don't know how to determine the position in a word document and insert into
particualar position.......
Please help me ....
Once again thank you for replay to me..
Thanks
Srinivas
Tim Forbis <[EMAIL PROTECTED]> wrote:
Hi Srinivas,
I am also new to POI, but I have worked exclusively with HWPF, so I might be able to
help a little bit. I have currently only worked with reading a Word file, but from the
classes it appears writing is in the same format.
What specifically do you mean by "Top left, top right, and bottom right position"? Are
we speaking of position on the main document page, or in headers and footers?
Thanks,
Tim Forbis
-----Original Message-----
From: Srinivas [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 24, 2004 12:42 AM
To: POI Users List
Subject: How to determine the position in word document using HWPF
Hi Friends,
Thank you for helping regularly. I am using POI in my application .I am able to
read/write the data from Word Document.And also using the Templates(ie Word Document
formats) in my application......
Now my problem is ....I need to create a template in word and then fill the document
at run time.And i will insert the Pre-defined arguments at run time at a particular
position(top left,top right and bottom right positions).But i am not able to get the
particular position in the Word Document.
Please help me How to find the particular position in the word document???
Thank you for your help.
Srinivas
---------------------------------
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]