0

I am using the last answer which is available in link: Replacing a text in Apache POI XWPF not working. Thanks to Josh.

It is working perfect for almost all scenarios, but sometimes it is not applying the color to the replaced text properly. am I missing something?

Community
  • 1
  • 1
kiranramanna
  • 115
  • 1
  • 9

1 Answers1

0

Runs are funny things. I know that the solution in this Stack Overflow question works great to replace sections of paragraphs or parts of runs that have different formatting (bold, embossed, etc) scattered throughout a given paragraph. For my particular use-case, the replace function was able to replace strings mid-run and handle any particular formatting that we were encountering. I didn't personally look at the color, but it appears to have functionality to do so: newRun.setColor(run.getColor());

Note that I originally was using Apache POI 3.11 and the code was giving me a lot of errors like "The method isEmbossed() is undefined for the type XWPFRun". Upgrading to 3.15 solved this.

Community
  • 1
  • 1