Venkatesh Goud Venkatesh Goud - 1 year ago 86
Java Question

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.

Answer Source

XWPF: See part 1 and 2 of my blog post on POI, here: 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.