Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert header and footer with POI HWPF?

 
juan sebastian sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi! I need your help!

how do you insert header and footer with POI HWPF? how can I replace a word in a World's document with POI wihtout a corruption file?

Thanks to somebody wich answer!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think HWPF supports adding headers or footers directly, but if you base your document on an existing one (as demonstrated in http://faq.javaranch.com/java/CreateWordDocument) you may be able to use any header/footer that happens to exist in that document already.

Replacing text inside of a DOC document is discussed in this topic.
 
juan sebastian sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:I don't think HWPF supports adding headers or footers directly, but if you base your document on an existing one (as demonstrated in http://faq.javaranch.com/java/CreateWordDocument) you may be able to use any header/footer that happens to exist in that document already.

Replacing text inside of a DOC document is discussed in this topic.


hi

when I replace words of different length the result file is corrupt

do you know why this happend?

thank for your help
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you doing the replacing? Post the relevant code here.
 
juan sebastian sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi the code that I am used are this two classes:
1- http://test.javaranch.com/ulf/InsertText.java
2- http://test.javaranch.com/ulf/ParagraphText.java
I am replacing the method piece.usesUnicode() for piece.isUnicode()
I am using POI 3.2 and also test with POI 3.5 beta 6
I have another class for replace words, is this:






but with both forms I have problems because the file get corrupted when the length of the old word and new word are differents betweenword
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the code that uses those two classes for replacing text.
 
juan sebastian sanchez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator









 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting. A doc file so changed is opened fine by both OpenOffice and Mellel (an OS X word processor), but not by Word itself. Might be something to ask on the POI mailing list about.
 
jetti madhu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is there any one know how to get the images from .doc file using POI ?
 
asif aftab
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://stackoverflow.com/questions/26250065/adding-footer-to-ms-word-using-poi-api/26250188#26250188
Please check above link. In this post footer is added perfectly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic