You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Srinivas Rao <sr...@yahoo.com> on 2004/07/22 07:06:40 UTC

How to Insert text into word document................

Hi Friends,
 
Thank you very much for sending the replay to me regularly.Now i am able to run the QuickTest.java and i am getting the text from the word document.
 
But i am not able to Insert the data into the word document.
My aim  is, I need to create a template in word and then fill the document at run time.

How to Solve this proble and send to me any references documents and examples Please....................
 
Thank you for your help.
 
 
Thanks
Srinivas

		
---------------------------------
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!

RE: How to Insert text into word document................

Posted by Braim <th...@hotmail.com>.
Hello everybody, 

I have the same need as Srinivas Rao. If someone can tell us how to create a
template and fill it at runtime, it will be very for him. 

Thanks 
Braim

-----Message d'origine-----
De : Srinivas Rao [mailto:srinivas2ps@yahoo.com] 
Envoyé : jeudi 22 juillet 2004 7:07
À : POI
Objet : How to Insert text into word document................

Hi Friends,
 
Thank you very much for sending the replay to me regularly.Now i am able to
run the QuickTest.java and i am getting the text from the word document.
 
But i am not able to Insert the data into the word document.
My aim  is, I need to create a template in word and then fill the document
at run time.

How to Solve this proble and send to me any references documents and
examples Please....................
 
Thank you for your help.
 
 
Thanks
Srinivas

		
---------------------------------
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!

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


Re: How to Insert text into word document................

Posted by "wolfgang.unger" <wo...@gmx.de>.
Hi,
this simple example works for me(should also work on your computer):
To jump to a special part(paragraph) of the doc, just
count the already existing paragraphs in your template doc and
move to the one you want to insert your text.
- Paragraph p = s.getParagraph(5 or whatever);
I'm just beginning to work with poi, so if anybody knows
better hints than me, feel free to correct my instructions.
Best regards wolfgang

-----------------------
    HWPFDocument doc = new HWPFDocument(new FileInputStream(strDocPath +
"2b.doc"));
      //simple
      Range r = doc.getRange();
      Section s = r.getSection(0);
      int np = s.numParagraphs() ;
      Paragraph p = s.getParagraph(np -1);
      int ncr = s.numCharacterRuns() ;
      CharacterRun run = p.getCharacterRun(0) ;

      CharacterProperties cp = new CharacterProperties();
      cp.setBold(true);
      s.insertAfter("text1 bold ",cp);
      cp.setBold(false);
      cp.setItalic(true);
      s.insertAfter("text2 italic ", cp);
      cp.setItalic(false);
      cp.setFontSize(30);
       s.insertAfter("text3 fontsize 30 ",cp );
      //save changes
      doc.write(new FileOutputStream(strDocPath + "2b.doc")) ;
--------------


> Hi wolfgang,
>
> H r u? i understood the mail,you are right.Before populate the template ,
i fill the pre-define data like today date and time at top left, address at
top right ........ete like that .... fill it with poi and then open word
document with this dot/doc as parameter.
>
> My proble is ,, I am able to read and write the data to word document .Now
,pre-defiend parameters are placed at particular position as above
parameters.
>
> And one more thing wolfgang, i am write the some data to word document,
now if i want to open that word document and modified if i save, the word
document is not saved ... Why it is not saved...I don't know what i am doing
wrong????
>
> Please help me .....  Solve this if you know the solution to this
problem....
>
> Thank you for replay to me..
>
> Thanks
>
> Srinivas
>
>
>
>
>
>
>
>
>
>
>
> wolfgang unger <wo...@gmx.de> wrote:
> Hi,
>
> I may be wrong, but as far I understood, HWPF(or poi) deals with
> the document itself, not with an Ole-Connection to Word or Exel.
> You can start word or
> excel with
> Runtime r = Runtime.getRuntime();
> Process p = r.exec("...\\winword.exe");
> but you will not be able to
> interact with the word instance
> like you could in c++ or visual basic.
> I don't know all regular parameters to start
> word, but I guess there should be a way to open
> word with an empty new document.
> I believe I would be easier to have a template(like
> a dot), fill it with poi and then open
> word with this dot/doc as parameter.
>
> best regards wolfgang
>
> > Srinivas Rao wrote:Hi Friends,
> >
> > Thank you very much for sending the replay to me regularly.Now i am able
> > to run the QuickTest.java and i am getting the text from the word
> document.
> >
> > But i am not able to Insert the data into the word document.
> > My aim is, I need to create a template in word and then fill the
document
> > at run time.
> >
> > How to Solve this proble and send to me any references documents and
> > examples Please....................
> >
> > Thank you for your help.
> >
> >
> > Thanks
> > Srinivas
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! Mail - 50x more storage than other providers!
> >
> >
> > ---------------------------------
> > Do you Yahoo!?
> > Vote for the stars of Yahoo!'s next ad campaign!
>
> --
> +++ GMX DSL-Tarife 3 Monate gratis* +++ Nur bis 25.7.2004 +++
> Bis 24.000 MB oder 300 Freistunden inkl. http://www.gmx.net/de/go/dsl
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Vote for the stars of Yahoo!'s next ad campaign!


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


Re: How to Insert text into word document................

Posted by Srinivas Rao <sr...@yahoo.com>.
Hi wolfgang,

H r u? i understood the mail,you are right.Before populate the template , i fill the pre-define data like today date and time at top left, address at top right ........ete like that .... fill it with poi and then open word document with this dot/doc as parameter.

My proble is ,, I am able to read and write the data to word document .Now ,pre-defiend parameters are placed at particular position as above parameters.

And one more thing wolfgang, i am write the some data to word document, now if i want to open that word document and modified if i save, the word document is not saved ... Why it is not saved...I don't know what i am doing wrong????

Please help me .....  Solve this if you know the solution to this problem....

Thank you for replay to me..

Thanks

Srinivas

 




 

 


wolfgang unger <wo...@gmx.de> wrote:
Hi,

I may be wrong, but as far I understood, HWPF(or poi) deals with 
the document itself, not with an Ole-Connection to Word or Exel.
You can start word or 
excel with
Runtime r = Runtime.getRuntime();
Process p = r.exec("...\\winword.exe");
but you will not be able to 
interact with the word instance
like you could in c++ or visual basic.
I don't know all regular parameters to start
word, but I guess there should be a way to open
word with an empty new document.
I believe I would be easier to have a template(like
a dot), fill it with poi and then open
word with this dot/doc as parameter.

best regards wolfgang

> Srinivas Rao wrote:Hi Friends,
> 
> Thank you very much for sending the replay to me regularly.Now i am able
> to run the QuickTest.java and i am getting the text from the word
document.
> 
> But i am not able to Insert the data into the word document.
> My aim is, I need to create a template in word and then fill the document
> at run time.
> 
> How to Solve this proble and send to me any references documents and
> examples Please....................
> 
> Thank you for your help.
> 
> 
> Thanks
> Srinivas
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Vote for the stars of Yahoo!'s next ad campaign!

-- 
+++ GMX DSL-Tarife 3 Monate gratis* +++ Nur bis 25.7.2004 +++
Bis 24.000 MB oder 300 Freistunden inkl. http://www.gmx.net/de/go/dsl


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


		
---------------------------------
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!

Re: How to Insert text into word document................

Posted by wolfgang unger <wo...@gmx.de>.
Hi,

I may be wrong, but as far I understood, HWPF(or poi) deals with 
the document itself, not with an Ole-Connection to Word or Exel.
You can start word or 
excel with
Runtime r = Runtime.getRuntime();
Process p = r.exec("...\\winword.exe");
but you will not be able to 
interact with the word instance
like you could in c++ or visual basic.
I don't know all regular parameters to start
word, but I guess there should be a way to open
word with an empty new document.
I believe I would be easier to have a template(like
a dot), fill it with poi and then open
word with this dot/doc as parameter.

best regards wolfgang

> Srinivas Rao <sr...@yahoo.com> wrote:Hi Friends,
> 
> Thank you very much for sending the replay to me regularly.Now i am able
> to run the QuickTest.java and i am getting the text from the word
document.
> 
> But i am not able to Insert the data into the word document.
> My aim is, I need to create a template in word and then fill the document
> at run time.
> 
> How to Solve this proble and send to me any references documents and
> examples Please....................
> 
> Thank you for your help.
> 
> 
> Thanks
> Srinivas
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> 
> 		
> ---------------------------------
> Do you Yahoo!?
> Vote for the stars of Yahoo!'s next ad campaign!

-- 
+++ GMX DSL-Tarife 3 Monate gratis* +++ Nur bis 25.7.2004 +++
Bis 24.000 MB oder 300 Freistunden inkl. http://www.gmx.net/de/go/dsl


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


How to Insert text into word document................

Posted by Srinivas Rao <sr...@yahoo.com>.

Srinivas Rao <sr...@yahoo.com> wrote:Hi Friends,

Thank you very much for sending the replay to me regularly.Now i am able to run the QuickTest.java and i am getting the text from the word document.

But i am not able to Insert the data into the word document.
My aim is, I need to create a template in word and then fill the document at run time.

How to Solve this proble and send to me any references documents and examples Please....................

Thank you for your help.


Thanks
Srinivas


---------------------------------
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!

		
---------------------------------
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!