Replacing a text in Apache POI XWPF

前端 未结 10 2252
鱼传尺愫
鱼传尺愫 2020-11-29 18:18

I just found Apache POI library very useful for editing Word files using Java. Specifically, I want to edit a DOCX file using Apache POI\'s XWPF classes. I

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 18:36

    I suggest my solution for replacing text between #, for example: This #bookmark# should be replaced. It is replace in:

    • paragraphs;
    • tables;
    • footers.

    Also, it takes into account situations, when symbol # and bookmark are in the separated runs (replace variable between different runs).

    Here link to the code: https://gist.github.com/aerobium/bf02e443c079c5caec7568e167849dda

提交回复
热议问题