Venkatesh Goud
Venkatesh Goud

Reputation: 636

How should i replace the string in word document with another string using poi?

i new to poi.i have a requirement to develop and edit the word document using poi.please send any sample examples for above question.

Upvotes: 1

Views: 3162

Answers (1)

TK Gospodinov
TK Gospodinov

Reputation: 8442

XWPF: See part 1 and 2 of my blog post on POI, here: http://tkgospodinov.com/writing-microsoft-word-documents-in-java-with-apache-poi/. You can use XWPFDocument#setParagraph to replace a whole paragraph with POI, so you can get the paragraph where you want to replace text, and create a new paragraph with the result and set it in place of the original. Keep in mind that this is new API since 3.7-beta2. I know it's a little convoluted, but currently that is the only way to accomplish that.

Upvotes: 1

Related Questions