{"id":443749,"date":"2025-01-01T09:00:39","date_gmt":"2025-01-01T09:00:39","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=443749"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2025-01-01T09:00:39","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=443749","title":{"rendered":"<span>\u041a\u043e\u0448\u043c\u0430\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 *.docx \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u043d\u0430 Java \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 XWPFDocument \u0438\u0437 API Apache POI<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 *.docx  \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u0447\u0451\u0442\u0430. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d \u0432\u0438\u0434\u0430 <em>&#171;{\u0448\u0430\u0431\u043b\u043e\u043d}&#187;<\/em> \u0438 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0446\u0432\u0435\u0442, \u0448\u0440\u0438\u0444\u0442, \u0440\u0430\u0437\u043c\u0435\u0440, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u043f\u0440), \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0432\u0438\u0434\u0430<br \/><code>{\u043d\u0430\u0447\u0430\u043b\u043e-\u0448\u0430\u0431\u043b\u043e\u043d\u0430-\u0434\u043b\u044f-\u043a\u0430\u0436\u0434\u043e\u0433\u043e-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430<br \/>     &lt;\u0432\u044b\u0432\u0435\u0441\u0442\u0438-\u0444\u0438\u043e-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430&gt; - &lt;\u0432\u044b\u0432\u0435\u0441\u0442\u0438-\u0432\u043e\u0437\u0440\u0430\u0441\u0442-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430&gt;<br \/>\u043a\u043e\u043d\u0435\u0446-\u0448\u0430\u0431\u043b\u043e\u043d\u0430-\u0434\u043b\u044f-\u043a\u0430\u0436\u0434\u043e\u0433\u043e-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430}<\/code><br \/>\u0422\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 (\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u044b, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438. \u041b\u044e\u0431\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430).<br \/>\u0414\u043e \u043a\u0443\u0447\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0447\u0435\u043c \u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0441\u0435\u0442\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 .docx \u043d\u0430 java.<br \/>\u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f.\u042f \u043f\u0438\u0448\u0443 \u0435\u0451 \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u0430\u043a\u043e\u043c \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0435\u0442\u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043e \u0433\u0440\u044f\u0437\u043d\u043e\u043c \u043a\u043e\u0434\u0435<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u0440\u044f\u0437\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u042f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u0433\u0440\u044f\u0437\u043d\u044b\u0439, \u043d\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0447\u0442\u043e \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0443 \u043c\u0435\u043d\u044f, \u0432 \u0442\u0435\u043b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430. \u0412\u0435\u0441\u044c\u043c\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0447\u0442\u043e \u0441\u0435\u0439 \u043a\u043e\u0434 \u0443\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0432\u0440\u043e\u0434\u0435 \u043a\u043e\u043b\u043e\u043d\u0442\u0438\u0442\u0443\u043b\u043e\u0432, \u0444\u0443\u0442\u0435\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 &#171;\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439&#187;.<br \/>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<br \/>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0445 \u0438 \u0440\u0438\u0441\u043a.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0447\u0435\u043c\u0443 XWPFDocument \u0438\u0437 API Apache POI \u044d\u0442\u043e &#171;\u0443\u0436\u0430\u0441 \u0443\u0436\u0430\u0441\u043d\u044b\u0439&#187;, \u0430 \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430\u0434\u043e \u0441\u043e\u0441\u043b\u0430\u0442\u044c \u0432 \u0430\u0440\u043a\u0442\u0438\u043a\u0443 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043d\u0435\u0436\u0438\u043d\u043a\u0438 \u043d\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430\u0445<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0434\u0432\u0430 \u0444\u0430\u043a\u0442\u0430<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 XWPFDocument \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 IBodyElement. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e IBodyElement \u044d\u0442\u043e \u043e\u0431\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 &#8212;  XWPFParagraph, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 &#8212; XWPFTable \u0438\u043b\u0438 \u043d\u0435\u0432\u0435\u0434\u043e\u043c\u0430\u044f \u0445\u0440\u0435\u043d\u044c \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c CONTENTCONTROL<em>.<br \/><\/em>\u041a\u0430\u0436\u0434\u044b\u0439 IBodyElement \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 &#171;\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f&#187;(getBody), \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0441\u0430\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f.<br \/>\u041f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<br \/>\u041c\u0435\u0442\u043e\u0434 getBody() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IBody \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430 \u043d\u0451\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f getElementType().<br \/>\u041b\u043e\u0433\u0438\u0447\u043d\u043e?<br \/>\u041b\u043e\u0433\u0438\u0447\u043d\u043e.<br \/>\u041d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430&#8230;<br \/>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u044b \u0441\u0442\u043e\u0438\u043c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0435 (\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 \u0442\u0435\u043a\u0441\u0442). \u041a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u043b\u0435\u0436\u0438\u0442?<br \/>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c getBody() \u043e\u0442 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430 (\u0438\u043b\u0438 \u043e\u0442 IBodyElement-\u0430 \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435) \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 IBody.<br \/>\u0427\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0435 \u0443\u0436\u0435 \u044d\u0442\u043e\u0442 \u043b\u0451\u0433\u043a\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0431\u0435\u0437\u0443\u043c\u0438\u044f?<br \/>\u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f IBodyElement, \u0430 \u0435\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c &#8212; IBody, \u0445\u043e\u0442\u044f \u044d\u0442\u043e, \u044f\u0432\u043d\u043e, \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<br \/>\u041b\u0430\u0434\u043d\u043e, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0432 \u044d\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0430\u0439\u043d\u044b\u0439 \u0441\u043c\u044b\u0441\u043b. \u041d\u043e \u043a\u0430\u043a \u043d\u0430\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430? \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438  \u043a\u0430\u043a\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430\u0448 IBody?<br \/>\u0410 \u043d\u0438\u043a\u0430\u043a! \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u043a\u0430\u043a. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043c\u043d\u0435 \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0447\u0435\u043d\u044c \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0451\u043a \u043d\u0430 \u043d\u0435\u0433\u043e \u0434\u0430\u0451\u0442 \u043c\u0435\u0442\u043e\u0434 getPart() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 POIXMLDocumentPart \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u043c OOXML.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0440\u043e\u0434\u0435: \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e IBodyElement-\u0430 \u0438\u043b\u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043d\u0438\u0436\u0435.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c \u043a\u043e\u0434\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 .docx \u0444\u0430\u0439\u043b\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0441\u043f\u0440\u0438\u043d\u0433\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">    @PostMapping(value = \"\/docx\", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})     public ResponseEntity&lt;Resource&gt; generateReportForTemplate(@RequestPart(\"file\") MultipartFile file, @RequestParam Map&lt;String, String&gt; allParams) {         MediaType contentType = MediaType.valueOf(file.getContentType());                  if (contentType.equals(MediaType.valueOf(\"application\/vnd.openxmlformats-officedocument.wordprocessingml.document\"))) {             XWPFDocument doc = new XWPFDocument(OPCPackage.open(file.getInputStream()));             ByteArrayOutputStream os = new ByteArrayOutputStream();              \/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 doc                       doc.write(os);            doc.close();            Resource fileResource = new InputStreamResource(new ByteArrayInputStream(os.toByteArray()));            os.close();             return ResponseEntity.ok()                     .contentType(contentType)                     .header(HttpHeaders.CONTENT_DISPOSITION, \"attachment; filename=\\\"\" + file.getOriginalFilename() + \"\\\"\")                     .body(fileResource);                     } else             throw new RuntimeException(\"\u041d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0444\u0430\u0439\u043b\u0430. \u0422\u043e\u043b\u044c\u043a\u043e docx-\u0444\u0430\u0439\u043b\u044b!\");     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 IBodyElement \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<pre><code class=\"java\">    \/**      * \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 - \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430      *\/     public static interface ProcessInterface {         \/**          * \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 IBodyElement. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u0438\u0441\u0442\u0438\u043d\u0443, \u0437\u043d\u0430\u0447\u0438\u0442 \u0446\u0435\u043b\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044b \u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f          *\/         public boolean process(IBodyElement iBodyElement);     }<\/code><\/pre>\n<p>\u0418 \u0441\u0430\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 IBodyElement \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e IBodyElement-\u0430 \u0438\u043b\u0438 \u0436\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<pre><code class=\"java\">    \/**      * \u0411\u0435\u0436\u0438\u043c \u043f\u043e \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 iBodyElement \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 processInterface.process      * \u0412\u044b\u0437\u0432\u0430\u0442\u044c \u043a\u0430\u043a      * for (IBodyElement iBodyElement : doc.getBodyElements())      * if (processDoc(iBodyElement, (ib) -&gt; {...})) break;      *      * @param iBodyElement     - \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0430\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0431\u0435\u0436\u0438\u043c      * @param processInterface - \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430      * @return - \u0438\u0441\u0442\u0438\u043d\u0430, \u0435\u0441\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0435\u0436\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e (\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0441\u0432\u043e\u0451 \u0434\u0435\u043b\u043e) \u0438 \u043b\u043e\u0436\u044c, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0430      *\/     public static boolean process(IBodyElement iBodyElement, ProcessInterface processInterface) {         if (BodyElementType.TABLE.equals(iBodyElement.getElementType())) {             for (XWPFTableRow row : ((XWPFTable) iBodyElement).getRows()) {                 for (XWPFTableCell cell : row.getTableCells()) {                     for (IBodyElement ibe : cell.getBodyElements()) {                         if (processInterface.process(ibe))                             return true;                         else if (process(ibe, processInterface))                             return true;                     }                 }             }             return false;         } else if (BodyElementType.PARAGRAPH.equals(iBodyElement.getElementType())) {             return processInterface.process(iBodyElement);         }          return false;     }<\/code><\/pre>\n<pre><code class=\"java\">    \/**      * \u0411\u0435\u0436\u0438\u043c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 IBodyElement \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 processInterface.process      * \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 IBodyElement-\u044b \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f!      * @param doc              - \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442      * @param processInterface - \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430      * @return - \u0438\u0441\u0442\u0438\u043d\u0430, \u0435\u0441\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0435\u0436\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e (\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0441\u0432\u043e\u0451 \u0434\u0435\u043b\u043e) \u0438 \u043b\u043e\u0436\u044c, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0430      *\/     public static boolean process(XWPFDocument doc, ProcessInterface processInterface) {         for (IBodyElement iBodyElement : doc.getBodyElements())             if (processInterface.process(iBodyElement))                 return true;         return false;     }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0438\u0436\u0435<\/p>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043c\u0435\u043d\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u0437\u044f\u0442\u044b\u0439 \u0438\u0437 <br \/><a href=\"https:\/\/stackoverflow.com\/questions\/71347456\/update-content-of-references-to-text-mark-in-docx\" rel=\"noopener noreferrer nofollow\">https:\/\/stackoverflow.com\/questions\/71347456\/update-content-of-references-to-text-mark-in-docx<\/a><br \/>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 <a href=\"https:\/\/www.baeldung.com\/java-replace-pattern-word-document-doc-docx\" rel=\"noopener noreferrer nofollow\">https:\/\/www.baeldung.com\/java-replace-pattern-word-document-doc-docx<\/a><\/p>\n<pre><code class=\"java\">    \/**      * \u041f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439      *      * @param doc     - \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442      * @param oldText - \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      * @param newText - \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      *\/     public static void replaceText(XWPFDocument doc, String oldText, String newText) {         process(doc, (iBodyElement) -&gt; {             return process(iBodyElement, (ib) -&gt; {                 if (ib.getElementType().equals(BodyElementType.PARAGRAPH)) {                     XWPFParagraph p = (XWPFParagraph) ib;                     replaceTextSegment(p, oldText, newText);                 }                  return false;             });         });     }      \/**      * \u041f\u043e \u0432\u0441\u0435\u043c\u0443 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 iBodyElement \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439      *      * @param iBodyElement - \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439      * @param oldText      - \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      * @param newText      - \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      *\/     public static void replaceText(IBodyElement iBodyElement, String oldText, String newText) {         process(iBodyElement, (ib) -&gt; {             if (ib.getElementType().equals(BodyElementType.PARAGRAPH)) {                 XWPFParagraph p = (XWPFParagraph) ib;                 replaceTextSegment(p, oldText, newText);             }             return false;         });     }       \/**      * \u0417\u0430\u043c\u0435\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a      * if (paragraph.getText().contains(textToFind)) { \/\/ paragraph contains text to find      * replaceTextSegment(paragraph, textToFind, replacement);      * }      *\/     static public void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement) {         TextSegment foundTextSegment = null;         PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);         while ((foundTextSegment = searchTextExt(paragraph, textToFind, startPos)) != null) { \/\/ search all text segments having text to find              \/\/ maybe there is text before textToFind in begin run             XWPFRun beginRun = paragraph.getRuns().get(foundTextSegment.getBeginRun());             String textInBeginRun = beginRun.getText(foundTextSegment.getBeginText());             String textBefore = textInBeginRun.substring(0, foundTextSegment.getBeginChar()); \/\/ we only need the text before              \/\/ maybe there is text after textToFind in end run             XWPFRun endRun = paragraph.getRuns().get(foundTextSegment.getEndRun());             String textInEndRun = endRun.getText(foundTextSegment.getEndText());             String textAfter = textInEndRun.substring(foundTextSegment.getEndChar() + 1); \/\/ we only need the text after              if (foundTextSegment.getEndRun() == foundTextSegment.getBeginRun()) {                 textInBeginRun = textBefore + replacement + textAfter; \/\/ if we have only one run, we need the text before, then the replacement, then the text after in that run             } else {                 textInBeginRun = textBefore + replacement; \/\/ else we need the text before followed by the replacement in begin run                 endRun.setText(textAfter, foundTextSegment.getEndText()); \/\/ and the text after in end run             }              beginRun.setText(textInBeginRun, foundTextSegment.getBeginText());              \/\/ runs between begin run and end run needs to be removed             for (int runBetween = foundTextSegment.getEndRun() - 1; runBetween &gt; foundTextSegment.getBeginRun(); runBetween--) {                 paragraph.removeRun(runBetween); \/\/ remove not needed runs             }          }     }      \/**      * this methods parse the paragraph and search for the string searched.      * If it finds the string, it will return true and the position of the String      * will be saved in the parameter startPos.      * &lt;p&gt;      * while((foundTextSegment = searchText(paragraph, textToFind, startPos)) != null)      *      * @param searched      * @param startPos      *\/     public static TextSegment searchTextExt(XWPFParagraph paragraph, String searched, PositionInParagraph startPos) {         int startRun = startPos.getRun(),                 startText = startPos.getText(),                 startChar = startPos.getChar();         int beginRunPos = 0, candCharPos = 0;         boolean newList = false;          \/\/CTR[] rArray = paragraph.getRArray(); \/\/This does not contain all runs. It lacks hyperlink runs for ex.         java.util.List&lt;XWPFRun&gt; runs = paragraph.getRuns();          int beginTextPos = 0, beginCharPos = 0; \/\/must be outside the for loop          for (int runPos = startRun; runPos &lt; runs.size(); runPos++) {             int textPos = 0, charPos;             CTR ctRun = runs.get(runPos).getCTR();             XmlCursor c = ctRun.newCursor();             c.selectPath(\".\/*\");             try {                 while (c.toNextSelection()) {                     XmlObject o = c.getObject();                     if (o instanceof CTText) {                         if (textPos &gt;= startText) {                             String candidate = ((CTText) o).getStringValue();                             if (runPos == startRun) {                                 charPos = startChar;                             } else {                                 charPos = 0;                             }                              for (; charPos &lt; (candidate==null ? 0 : candidate.length()); charPos++) {                                 if ((candidate.charAt(charPos) == searched.charAt(0)) &amp;&amp; (candCharPos == 0)) {                                     beginTextPos = textPos;                                     beginCharPos = charPos;                                     beginRunPos = runPos;                                     newList = true;                                 }                                 if (candidate.charAt(charPos) == searched.charAt(candCharPos)) {                                     if (candCharPos + 1 &lt; searched.length()) {                                         candCharPos++;                                     } else if (newList) {                                         TextSegment segment = new TextSegment();                                         segment.setBeginRun(beginRunPos);                                         segment.setBeginText(beginTextPos);                                         segment.setBeginChar(beginCharPos);                                         segment.setEndRun(runPos);                                         segment.setEndText(textPos);                                         segment.setEndChar(charPos);                                         return segment;                                     }                                 } else {                                     candCharPos = 0;                                 }                             }                         }                         textPos++;                     } else if (o instanceof CTProofErr) {                         c.removeXml();                     } else if (o instanceof CTRPr) {                         \/\/do nothing                     } else {                         candCharPos = 0;                     }                 }             } finally {                 c.dispose();             }         }         return null;     } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">    \/**      * \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430      *\/     public static String getText(XWPFDocument doc) throws IOException {         XWPFWordExtractor ex = new XWPFWordExtractor(doc);         return ex.getText();\/\/xdoc.getDocument().toString();     }      \/**      * \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435)      *\/     public static String getText(List&lt;IBodyElement&gt; iBodyElements){         StringBuilder sb = new StringBuilder();         iBodyElements.forEach(iBodyElement -&gt; process(iBodyElement, ib -&gt; {             if (ib.getElementType().equals(BodyElementType.PARAGRAPH)) {                 XWPFParagraph p = (XWPFParagraph) ib;                 sb.append(p.getText());             }             return false;         }));         return sb.toString();     }       \/**      * \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0442\u0435\u0440\u043d\u043e\u0432 \u043e\u0431\u0440\u0430\u043c\u043b\u0451\u043d\u043d\u044b\u0445 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0441\u044f \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0441\u044f \u0442\u044d\u0433\u0430\u043c\u0438. \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442      *      * @param text     - \u0442\u0435\u043a\u0441\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0449\u0435\u043c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u0442\u0435\u0440\u043d\u043e\u0432      * @param begin    - \u043e\u0442\u0440\u043a\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433      * @param end      - \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433      * @param withTags - \u0435\u0441\u043b\u0438 \u0438\u0441\u0442\u0438\u043d\u0430, \u0442\u043e \u0432\u0435\u0440\u043d\u0451\u0442 \u043f\u0430\u0442\u0435\u0440\u043d\u044b \u0432\u0441\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u044d\u0433\u0430\u043c\u0438      * @return - \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0442\u0435\u0440\u043d\u043e\u0432      *\/     public static List&lt;String&gt; getAllTextsBetweenTags(String text, String begin, String end, Boolean withTags) {         List&lt;String&gt; list = new ArrayList&lt;&gt;();         int ibegin = 0;         int iend = 0;         while (true) {             ibegin = text.indexOf(begin, iend);             iend = text.indexOf(end, ibegin + 1);             if (ibegin == -1 || iend == -1) break;             list.add((withTags ? begin : \"\") + text.substring(ibegin + begin.length(), iend) + (withTags ? end : \"\"));         }         return list;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">   \/**      * \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d iBodyElement \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 body \u043d\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043a\u0443\u0440\u0441\u043e\u0440\u0430 (\u0432\u0430\u0436\u043d\u043e, \u043a\u0443\u0440\u0441\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 body, \u0438\u043d\u0430\u0447\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u0441\u043a\u043b)      * \u0415\u0441\u043b\u0438 \u043a\u0443\u0440\u0441\u043e\u0440 \u043d\u0443\u043b\u043b \u0438\u043b\u0438 \u0431\u043e\u0434\u0443 \u043d\u0443\u043b\u043b, \u0442\u043e \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u0430 \u0435\u0433\u043e body      *      * @param body         - \u043c\u0435\u0441\u0442\u043e \u043a\u0443\u0434\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u0434 \u043d\u0435\u0433\u043e)      * @param cursor       - \u043a\u0443\u0440\u0441\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438      * @param iBodyElement - \u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b      * @return - \u043a\u043e\u043f\u0438\u044e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430      *\/     public static IBodyElement cloneIbodyElement(IBody body, IBodyElement iBodyElement, XmlCursor cursor) {         IBodyElement iBodyElementNew = null;         if (iBodyElement.getElementType().equals(BodyElementType.PARAGRAPH)) {             if (cursor == null || body == null) {                 if (body == null)                     body = iBodyElement.getBody();                 if (cursor == null) {                     cursor = ((XWPFParagraph) iBodyElement).getCTP().newCursor();                     cursor.toNextSibling();                 }             }             iBodyElementNew = body.insertNewParagraph(cursor);             UtilXWPFDocument.cloneParagraph((XWPFParagraph) iBodyElementNew, (XWPFParagraph) iBodyElement);         }         if (iBodyElement.getElementType().equals(BodyElementType.TABLE)) {             if (cursor == null || body == null) {                 body = iBodyElement.getBody();                 cursor = ((XWPFTable) iBodyElement).getCTTbl().newCursor();             }             iBodyElementNew = body.insertNewTbl(cursor);             ((XWPFTable) iBodyElementNew).getCTTbl().set(((XWPFTable) iBodyElement).getCTTbl());             UtilXWPFDocument.copyTable((XWPFTable) iBodyElement, (XWPFTable) iBodyElementNew);         }         cursor.toNextToken();         return iBodyElementNew;     }      \/**      * \u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 IBodyElement \u0432 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e cursor \u0438\u043b\u0438, \u043f\u0440\u0438 \u0435\u0433\u043e \u043e\u0442\u0441\u0443\u0442\u0432\u0438\u0438, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f      *      * @param cursor - \u043a\u0443\u0440\u0441\u043e\u0440 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u043f\u0443\u0441\u0442, \u0442\u043e \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435      * @param copis  - \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432      * @return - \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432      *\/     public static List&lt;IBodyElement&gt; cloneIbodyElements(IBody body, XmlCursor cursor, List&lt;IBodyElement&gt; copis) {         if (cursor == null || body == null) {             IBodyElement lastElement = copis.get(copis.size() - 1);             if (body == null)                 body = lastElement.getBody();             if (cursor == null) {                 cursor = lastElement.getElementType().equals(BodyElementType.PARAGRAPH) ? ((XWPFParagraph) lastElement).getCTP().newCursor() : ((XWPFTable) lastElement).getCTTbl().newCursor();                 cursor.toNextSibling();             }         }         List&lt;IBodyElement&gt; resp = new ArrayList&lt;&gt;();         for (IBodyElement ib : copis) {             \/\/\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0442\u0443\u0434\u0430 \u0442\u0435\u043a\u0441\u0442 \u0438\u0437 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u0433\u043e             IBodyElement new_ib = UtilXWPFDocument.cloneIbodyElement(body, ib, cursor);             resp.add(new_ib);         }         return resp;     }       \/**      * \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u0432 \u043d\u043e\u0432\u044b\u0439, \u043f\u0443\u0441\u0442\u043e\u0439, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444.      * \u041d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d      * }      *\/     public static void cloneParagraph(XWPFParagraph clone, XWPFParagraph source) {\/\/https:\/\/stackoverflow.com\/questions\/23112924\/make-an-exact-copy-of-a-paragraph-including-all-contents-and-properties         CTPPr pPr = clone.getCTP().isSetPPr() ? clone.getCTP().getPPr() : clone.getCTP().addNewPPr();         pPr.set(source.getCTP().getPPr());         for (XWPFRun r : source.getRuns()) {             XWPFRun nr = clone.createRun();             cloneRun(nr, r);         }     }      public static void cloneRun(XWPFRun clone, XWPFRun source) {         CTRPr rPr = clone.getCTR().isSetRPr() ? clone.getCTR().getRPr() : clone.getCTR().addNewRPr();         rPr.set(source.getCTR().getRPr());         clone.setText(source.getText(0));     }      \/** \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043d\u043e\u0432\u0443\u044e, \u043f\u0443\u0441\u0442\u0443\u044e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443      * https:\/\/stackoverflow.com\/questions\/48322534\/apache-poi-how-to-copy-tables-from-one-docx-to-another-docx      *       * XWPFTable newTbl = output_doc.insertNewTbl(cursor);      * copyTable(table, newTbl);      *\/     public static void copyTable(XWPFTable source, XWPFTable target) {         target.getCTTbl().setTblPr(source.getCTTbl().getTblPr());         target.getCTTbl().setTblGrid(source.getCTTbl().getTblGrid());          \/\/newly created table has one row by default. we need to remove the default row.         target.removeRow(0);          for (int r = 0; r &lt; source.getRows().size(); r++) {             XWPFTableRow targetRow = target.createRow();             XWPFTableRow row = source.getRows().get(r);             targetRow.getCtRow().setTrPr(row.getCtRow().getTrPr());             for (int c = 0; c &lt; row.getTableCells().size(); c++) {                 \/\/newly created row has 1 cell                 XWPFTableCell targetCell = targetRow.createCell();                 XWPFTableCell cell = row.getTableCells().get(c);                 targetCell.getCTTc().setTcPr(cell.getCTTc().getTcPr());                 XmlCursor cursor = targetCell.getParagraphArray(0).getCTP().newCursor();                 for (int p = 0; p &lt; cell.getBodyElements().size(); p++) {                     IBodyElement elem = cell.getBodyElements().get(p);                     if (elem instanceof XWPFParagraph) {                         XWPFParagraph targetPar = targetCell.insertNewParagraph(cursor);                         cursor.toNextToken();                         XWPFParagraph par = (XWPFParagraph) elem;                         \/\/copyParagraph(par, targetPar);                         cloneParagraph(targetPar, par);                     } else if (elem instanceof XWPFTable) {                         XWPFTable targetTable = targetCell.insertNewTbl(cursor);                         XWPFTable table = (XWPFTable) elem;                         copyTable(table, targetTable);                         cursor.toNextToken();                     }                 }                 \/\/newly created cell has one default paragraph we need to remove                 targetCell.removeParagraph(targetCell.getParagraphs().size() - 1);             }         }     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435  \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">    \/**      * \u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044f \u0435\u0433\u043e      *\/     public static void clearParagraph(final XWPFParagraph p) {         \/\/p.getCTP().getRList().clear();          for (XWPFRun r : p.getRuns())             r.setText(\"\", 0);     }       \/**      * \u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044f \u0435\u0433\u043e. \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u0433\u0440\u0444\u044b \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043b\u044e\u0431\u044b\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438      *\/     public static void clearTable(final XWPFTable table) {        process(table,iBodyElement-&gt;{            if (iBodyElement.getElementType().equals(BodyElementType.PARAGRAPH)) {                XWPFParagraph p = (XWPFParagraph) iBodyElement;                clearParagraph(p);            }            return false;        });     }      \/**      * \u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0431\u043e\u0434\u0438-\u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043e\u0442 \u0442\u0435\u043a\u0441\u0442\u0430      *\/     public static void clearElement(final IBodyElement iBodyElement) {         if (iBodyElement.getElementType().equals(BodyElementType.PARAGRAPH)) clearParagraph((XWPFParagraph) iBodyElement);         if (iBodyElement.getElementType().equals(BodyElementType.TABLE)) clearTable((XWPFTable) iBodyElement);     }      \/**      * \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e IBodyElement (\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043b\u0438 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430)      *\/     public static void removeBodyElement(IBodyElement iBodyElement) {         IBody body = iBodyElement.getBody();         if (body instanceof XWPFDocument) {             final XWPFDocument doreplacedent = (XWPFDocument) body;             final int index = doreplacedent.getBodyElements().indexOf(iBodyElement);             if (index != -1) {                 doreplacedent.removeBodyElement(index);             }         } else if (body instanceof XWPFHeaderFooter) {             final XWPFHeaderFooter headerFooter = (XWPFHeaderFooter) body;             if (iBodyElement.getElementType().equals(BodyElementType.PARAGRAPH))                 headerFooter.removeParagraph((XWPFParagraph) iBodyElement);             if (iBodyElement.getElementType().equals(BodyElementType.TABLE))                 headerFooter.removeTable((XWPFTable) iBodyElement);         } else if (body instanceof XWPFTableCell) {             final XWPFTableCell cell = (XWPFTableCell) body;             if (iBodyElement.getElementType().equals(BodyElementType.PARAGRAPH)) {                 final int index = cell.getParagraphs().indexOf(iBodyElement);                 if (index != -1)                     cell.removeParagraph(index);             }             if (iBodyElement.getElementType().equals(BodyElementType.TABLE)) {                 final int index = cell.getTables().indexOf(iBodyElement);                 if (index != -1)                     cell.removeTable(index);             }         } else {             throw new IllegalStateException(\"can't delete\");         }     }       \/**      * \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0441 body \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0435\u043c\u0443 bodyElements \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 ibegin \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f iend      *\/     public static void deleteBodyElementsFromBody(IBody body, int ibegin, int iend) {         List&lt;IBodyElement&gt; dels = Lists.newArrayList(body.getBodyElements().subList(ibegin, iend + 1).iterator());         \/\/\u0435\u0441\u043b\u0438 \u043c\u044b \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0451, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0442\u0435\u043b\u0435, \u0442\u043e \u044d\u0442\u043e \u043e\u0441\u043e\u0431\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u0438\u043d\u0430\u0447\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0451\u043d (\u0432\u0438\u0434\u0438\u043c\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u0432\u0437\u044f\u043b\u0438 \u043a\u0443\u0440\u0441\u043e\u0440 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430)         if (body.getBodyElements().equals(dels)) {             UtilXWPFDocument.clearParagraph((XWPFParagraph) dels.get(dels.size() - 1));\/\/\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430 \u0431\u0435\u0437 \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f             dels = Lists.newArrayList(dels.subList(0, dels.size() - 1).iterator()); \/\/\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444         }          for (IBodyElement ib : dels)             UtilXWPFDocument.removeBodyElement(ib);     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u043e \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043d\u0435\u043a\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0442\u044d\u0433\u0430 \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">    \/**      * \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0432\u0435\u0441\u044c \u0442\u0435\u043a\u0441\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0442\u044d\u0433\u0430 \u0438 \u043a\u043e\u043d\u0447\u0430\u044f \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u0442\u044d\u0433\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u043b\u0435\u044c\u043d\u043e. \u041e\u0442\u043a \u0438 \u0437\u0430\u043a\u0440 \u0442\u044d\u0433\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438      *      * @param doc    - \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442      * @param sbegin - \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433      * @param send   - \u0437\u0430\u043a\u0440\u044b\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433      *\/     public static void deleteText(XWPFDocument doc, String sbegin, String send) {         class TemplateWork extends TemplateWorkAbstract {              public TemplateWork(String sbegin, String send) {                 super(sbegin, send);             }              @Override             public void processTemplate() {                 deleteBodyElementsFromBody(body, ibegin, iend);             }         }          TemplateWorkAbstract templateWork = new TemplateWork(sbegin, send);         findAndProcessTemplate(doc, templateWork);     }      \/**      * \u041a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435  findAndProcessTemplate      *\/     @FieldDefaults(level = AccessLevel.PUBLIC)     public static abstract class TemplateWorkAbstract {         IBody body;         String sbegin;\/\/\u043e\u0442\u0440\u043a\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433 \u0434\u043b\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430         String send;\/\/\u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433 \u0434\u043b\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430         int ibegin = -1;\/\/\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430 \u0433\u0434\u0435 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 body.getBodyElements.get(?)         int iend = -1;\/\/\u043f\u043e\u0446\u0438\u0437\u0438\u0439\u0438\u044f \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430 \u0433\u0434\u0435 \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433 \u0448\u0430\u0431\u043b\u043e\u043d\u0430          public TemplateWorkAbstract(String sbegin, String send) {             this.sbegin = sbegin;             this.send = send;         }          public void reset() {\/\/\u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c             body = null;             ibegin = -1;             iend = -1;         }          public void findBegin(XWPFParagraph p, int i) {\/\/\u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0433\u0434\u0435 p - \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433             ibegin = i;         }          public void findEnd(XWPFParagraph p, int i) {\/\/\u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0446\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0433\u0434\u0435 p - \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u044d\u0433             iend = i;         }          public abstract void processTemplate();\/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430     }      \/**      * \u041d\u0430\u0439\u0442\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u0432\u0441\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u0442\u044d\u0433 templateWork.sbegin \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u0442\u044d\u0433 templateWork.send \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0445, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u044f templateWork.processTemplate()      *      * @param doc          - \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442      * @param templateWork - \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0442 TemplateWorkAbstract \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0446\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430      *\/     public static void findAndProcessTemplate(XWPFDocument doc, TemplateWorkAbstract templateWork) {         templateWork.reset();         while (process(doc, (iBodyElement) -&gt; {             return process(iBodyElement, (ib) -&gt; {                 return templateFind(templateWork, ib);             });         })) {             templateProcess(templateWork);         }     }      \/**      * \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432 templateWork. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 {@see templateFind}      *\/     private static void templateProcess(TemplateWorkAbstract templateWork) {         templateWork.processTemplate();         templateWork.reset();     }      \/**      * \u041d\u0430\u0439\u0442\u0438 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e templateWork \u0432\u043d\u0443\u0442\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e IBodyElement (\u0432\u0435\u0440\u043d\u0451\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 templateWork)      *\/     private static boolean templateFind(TemplateWorkAbstract templateWork, IBodyElement ib) {         if (ib.getElementType().equals(BodyElementType.PARAGRAPH)) {             XWPFParagraph p = (XWPFParagraph) ib;             if (p.getText().contains(templateWork.sbegin)) {                 templateWork.body = p.getBody();                 int i = 0;                 for (IBodyElement ww : p.getBody().getBodyElements()) {                     if (ww.getElementType().equals(BodyElementType.PARAGRAPH)) {                         XWPFParagraph ee = (XWPFParagraph) ww;                         if (ee.getText().contains(templateWork.sbegin))                             templateWork.findBegin(ee, i);                         else if (ee.getText().contains(templateWork.send)) {                             templateWork.findEnd(ee, i);                             break;                         }                     }                     i++;                 }                 if (templateWork.iend == -1)                     throw new RuntimeException(\"\u041d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0434\u043b\u044f: \" + templateWork.sbegin);                 else {                     return true;                 }             }         }         return false;     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">\/\/\u041f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 UtilXWPFDocument.replaceText(doc, \"\u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\", \"\u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442\");  \/\/\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0432\u0438\u0434\u0430 &lt;dataset&gt;\u043d\u0435\u043a\u0438\u0439 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d&lt;\/dataset&gt; \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 List&lt;String&gt; stringDatasets = UtilXWPFDocument.getAllTextsBetweenTags(UtilXWPFDocument.getText(doc), \"&lt;dataset&gt;\", \"&lt;\/dataset&gt;\", true);  \/\/\u0418 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u044d\u0442\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 UtilXWPFDocument.deleteText(doc, \"&lt;dataset&gt;\", \"&lt;\/dataset&gt;\");  \/\/\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 iBodyElement-\u043e\u0432 (\u0438 \u0432\u0441\u0435\u0445 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0432 \u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432) \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a doc.getBodyElements()        iBodyElements.forEach(iBodyElement -&gt; {             UtilXWPFDocument.process(iBodyElement, (ib) -&gt; {               \/\/\u043d\u0435\u043a\u0438\u0439 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e ib-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430               return false;             });         });  \/\/\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e ib-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435. \/\/\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u0438\u0441\u0442\u0438\u043d\u0443 boolean isProcessing=process(doc, (iBodyElement) -&gt; {             return process(iBodyElement, (ib) -&gt; {                 return \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f-\u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438(ib);             });         });<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/870544\/\"> https:\/\/habr.com\/ru\/articles\/870544\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 *.docx  \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u0447\u0451\u0442\u0430. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d \u0432\u0438\u0434\u0430 <em>&#171;{\u0448\u0430\u0431\u043b\u043e\u043d}&#187;<\/em> \u0438 \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0446\u0432\u0435\u0442, \u0448\u0440\u0438\u0444\u0442, \u0440\u0430\u0437\u043c\u0435\u0440, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u043f\u0440), \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043c\u0435\u043d\u044b \u044d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0432\u0438\u0434\u0430<br \/><code>{\u043d\u0430\u0447\u0430\u043b\u043e-\u0448\u0430\u0431\u043b\u043e\u043d\u0430-\u0434\u043b\u044f-\u043a\u0430\u0436\u0434\u043e\u0433\u043e-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430<br \/>     &lt;\u0432\u044b\u0432\u0435\u0441\u0442\u0438-\u0444\u0438\u043e-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430&gt; - &lt;\u0432\u044b\u0432\u0435\u0441\u0442\u0438-\u0432\u043e\u0437\u0440\u0430\u0441\u0442-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430&gt;<br \/>\u043a\u043e\u043d\u0435\u0446-\u0448\u0430\u0431\u043b\u043e\u043d\u0430-\u0434\u043b\u044f-\u043a\u0430\u0436\u0434\u043e\u0433\u043e-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430}<\/code><br \/>\u0422\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 (\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u044b, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438. \u041b\u044e\u0431\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430).<br \/>\u0414\u043e \u043a\u0443\u0447\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0440\u0443\u0433 \u0432 \u0434\u0440\u0443\u0433\u0430, \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0447\u0435\u043c \u0438 \u0434\u043b\u044f \u043a\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0441\u0435\u0442\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 .docx \u043d\u0430 java.<br \/>\u0427\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f.\u042f \u043f\u0438\u0448\u0443 \u0435\u0451 \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u0430\u043a\u043e\u043c \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432 \u0441\u0435\u0442\u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043e \u0433\u0440\u044f\u0437\u043d\u043e\u043c \u043a\u043e\u0434\u0435<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u0440\u044f\u0437\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u042f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u0443\u044e \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u0433\u0440\u044f\u0437\u043d\u044b\u0439, \u043d\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0447\u0442\u043e \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0443 \u043c\u0435\u043d\u044f, \u0432 \u0442\u0435\u043b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430. \u0412\u0435\u0441\u044c\u043c\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0447\u0442\u043e \u0441\u0435\u0439 \u043a\u043e\u0434 \u0443\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438 \u0432\u0440\u043e\u0434\u0435 \u043a\u043e\u043b\u043e\u043d\u0442\u0438\u0442\u0443\u043b\u043e\u0432, \u0444\u0443\u0442\u0435\u0440\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 &#171;\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439&#187;.<br \/>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<br \/>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0445 \u0438 \u0440\u0438\u0441\u043a.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0447\u0435\u043c\u0443 XWPFDocument \u0438\u0437 API Apache POI \u044d\u0442\u043e &#171;\u0443\u0436\u0430\u0441 \u0443\u0436\u0430\u0441\u043d\u044b\u0439&#187;, \u0430 \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0430\u0434\u043e \u0441\u043e\u0441\u043b\u0430\u0442\u044c \u0432 \u0430\u0440\u043a\u0442\u0438\u043a\u0443 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043d\u0435\u0436\u0438\u043d\u043a\u0438 \u043d\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430\u0445<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0434\u0432\u0430 \u0444\u0430\u043a\u0442\u0430<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 XWPFDocument \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 IBodyElement. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e IBodyElement \u044d\u0442\u043e \u043e\u0431\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 &#8212;  XWPFParagraph, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 &#8212; XWPFTable \u0438\u043b\u0438 \u043d\u0435\u0432\u0435\u0434\u043e\u043c\u0430\u044f \u0445\u0440\u0435\u043d\u044c \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c CONTENTCONTROL<em>.<br \/><\/em>\u041a\u0430\u0436\u0434\u044b\u0439 IBodyElement \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 &#171;\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f&#187;(getBody), \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0441\u0430\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f.<br \/>\u041f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<br \/>\u041c\u0435\u0442\u043e\u0434 getBody() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 IBody \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430 \u043d\u0451\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f getElementType().<br \/>\u041b\u043e\u0433\u0438\u0447\u043d\u043e?<br \/>\u041b\u043e\u0433\u0438\u0447\u043d\u043e.<br \/>\u041d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430&#8230;<br \/>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u044b \u0441\u0442\u043e\u0438\u043c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0435 (\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 \u0442\u0435\u043a\u0441\u0442). \u041a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u043b\u0435\u0436\u0438\u0442?<br \/>\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c getBody() \u043e\u0442 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430 (\u0438\u043b\u0438 \u043e\u0442 IBodyElement-\u0430 \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435) \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 IBody.<br \/>\u0427\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0435 \u0443\u0436\u0435 \u044d\u0442\u043e\u0442 \u043b\u0451\u0433\u043a\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0431\u0435\u0437\u0443\u043c\u0438\u044f?<br \/>\u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f IBodyElement, \u0430 \u0435\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c &#8212; IBody, \u0445\u043e\u0442\u044f \u044d\u0442\u043e, \u044f\u0432\u043d\u043e, \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<br \/>\u041b\u0430\u0434\u043d\u043e, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0432 \u044d\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0430\u0439\u043d\u044b\u0439 \u0441\u043c\u044b\u0441\u043b. \u041d\u043e \u043a\u0430\u043a \u043d\u0430\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430? \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438  \u043a\u0430\u043a\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043b\u0435\u0436\u0438\u0442 \u043d\u0430\u0448 IBody?<br \/>\u0410 \u043d\u0438\u043a\u0430\u043a! \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u043a\u0430\u043a. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043c\u043d\u0435 \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0447\u0435\u043d\u044c \u043e\u0442\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0451\u043a \u043d\u0430 \u043d\u0435\u0433\u043e \u0434\u0430\u0451\u0442 \u043c\u0435\u0442\u043e\u0434 getPart() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 POIXMLDocumentPart \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043d\u0438\u0437\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u043c OOXML.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0440\u0435\u0448\u0438\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u0440\u043e\u0434\u0435: \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e IBodyElement-\u0430 \u0438\u043b\u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043d\u0438\u0436\u0435.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/details>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c \u043a\u043e\u0434\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 .docx \u0444\u0430\u0439\u043b\u0430 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0441\u043f\u0440\u0438\u043d\u0433\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">    @PostMapping(value = \"\/docx\", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})     public ResponseEntity&lt;Resource&gt; generateReportForTemplate(@RequestPart(\"file\") MultipartFile file, @RequestParam Map&lt;String, String&gt; allParams) {         MediaType contentType = MediaType.valueOf(file.getContentType());                  if (contentType.equals(MediaType.valueOf(\"application\/vnd.openxmlformats-officedocument.wordprocessingml.document\"))) {             XWPFDocument doc = new XWPFDocument(OPCPackage.open(file.getInputStream()));             ByteArrayOutputStream os = new ByteArrayOutputStream();              \/\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 doc                       doc.write(os);            doc.close();            Resource fileResource = new InputStreamResource(new ByteArrayInputStream(os.toByteArray()));            os.close();             return ResponseEntity.ok()                     .contentType(contentType)                     .header(HttpHeaders.CONTENT_DISPOSITION, \"attachment; filename=\\\"\" + file.getOriginalFilename() + \"\\\"\")                     .body(fileResource);                     } else             throw new RuntimeException(\"\u041d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0444\u0430\u0439\u043b\u0430. \u0422\u043e\u043b\u044c\u043a\u043e docx-\u0444\u0430\u0439\u043b\u044b!\");     }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 IBodyElement \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<pre><code class=\"java\">    \/**      * \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 - \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430      *\/     public static interface ProcessInterface {         \/**          * \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 IBodyElement. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u0438\u0441\u0442\u0438\u043d\u0443, \u0437\u043d\u0430\u0447\u0438\u0442 \u0446\u0435\u043b\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044b \u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f          *\/         public boolean process(IBodyElement iBodyElement);     }<\/code><\/pre>\n<p>\u0418 \u0441\u0430\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0441\u0435\u0445 IBodyElement \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e IBodyElement-\u0430 \u0438\u043b\u0438 \u0436\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<\/p>\n<pre><code class=\"java\">    \/**      * \u0411\u0435\u0436\u0438\u043c \u043f\u043e \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 iBodyElement \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 processInterface.process      * \u0412\u044b\u0437\u0432\u0430\u0442\u044c \u043a\u0430\u043a      * for (IBodyElement iBodyElement : doc.getBodyElements())      * if (processDoc(iBodyElement, (ib) -&gt; {...})) break;      *      * @param iBodyElement     - \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0430\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0431\u0435\u0436\u0438\u043c      * @param processInterface - \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430      * @return - \u0438\u0441\u0442\u0438\u043d\u0430, \u0435\u0441\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0435\u0436\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e (\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0441\u0432\u043e\u0451 \u0434\u0435\u043b\u043e) \u0438 \u043b\u043e\u0436\u044c, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0430      *\/     public static boolean process(IBodyElement iBodyElement, ProcessInterface processInterface) {         if (BodyElementType.TABLE.equals(iBodyElement.getElementType())) {             for (XWPFTableRow row : ((XWPFTable) iBodyElement).getRows()) {                 for (XWPFTableCell cell : row.getTableCells()) {                     for (IBodyElement ibe : cell.getBodyElements()) {                         if (processInterface.process(ibe))                             return true;                         else if (process(ibe, processInterface))                             return true;                     }                 }             }             return false;         } else if (BodyElementType.PARAGRAPH.equals(iBodyElement.getElementType())) {             return processInterface.process(iBodyElement);         }          return false;     }<\/code><\/pre>\n<pre><code class=\"java\">    \/**      * \u0411\u0435\u0436\u0438\u043c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 IBodyElement \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 processInterface.process      * \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 IBodyElement-\u044b \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f!      * @param doc              - \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442      * @param processInterface - \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430      * @return - \u0438\u0441\u0442\u0438\u043d\u0430, \u0435\u0441\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0435\u0436\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e (\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0441\u0432\u043e\u0451 \u0434\u0435\u043b\u043e) \u0438 \u043b\u043e\u0436\u044c, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0430      *\/     public static boolean process(XWPFDocument doc, ProcessInterface processInterface) {         for (IBodyElement iBodyElement : doc.getBodyElements())             if (processInterface.process(iBodyElement))                 return true;         return false;     }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0438\u0436\u0435<\/p>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043c\u0435\u043d\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u0437\u044f\u0442\u044b\u0439 \u0438\u0437 <br \/><a href=\"https:\/\/stackoverflow.com\/questions\/71347456\/update-content-of-references-to-text-mark-in-docx\" rel=\"noopener noreferrer nofollow\">https:\/\/stackoverflow.com\/questions\/71347456\/update-content-of-references-to-text-mark-in-docx<\/a><br \/>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 <a href=\"https:\/\/www.baeldung.com\/java-replace-pattern-word-document-doc-docx\" rel=\"noopener noreferrer nofollow\">https:\/\/www.baeldung.com\/java-replace-pattern-word-document-doc-docx<\/a><\/p>\n<pre><code class=\"java\">    \/**      * \u041f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439      *      * @param doc     - \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442      * @param oldText - \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      * @param newText - \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      *\/     public static void replaceText(XWPFDocument doc, String oldText, String newText) {         process(doc, (iBodyElement) -&gt; {             return process(iBodyElement, (ib) -&gt; {                 if (ib.getElementType().equals(BodyElementType.PARAGRAPH)) {                     XWPFParagraph p = (XWPFParagraph) ib;                     replaceTextSegment(p, oldText, newText);                 }                  return false;             });         });     }      \/**      * \u041f\u043e \u0432\u0441\u0435\u043c\u0443 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 iBodyElement \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439      *      * @param iBodyElement - \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439      * @param oldText      - \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      * @param newText      - \u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442      *\/     public static void replaceText(IBodyElement iBodyElement, String oldText, String newText) {         process(iBodyElement, (ib) -&gt; {             if (ib.getElementType().equals(BodyElementType.PARAGRAPH)) {                 XWPFParagraph p = (XWPFParagraph) ib;                 replaceTextSegment(p, oldText, newText);             }             return false;         });     }       \/**      * \u0417\u0430\u043c\u0435\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043f\u0430\u0440\u0430\u0433\u0440\u0430\u0444\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a      * if (paragraph.getText().contains(textToFind)) { \/\/ paragraph contains text to find      * replaceTextSegment(paragraph, textToFind, replacement);      * }      *\/     static public void replaceTextSegment(XWPFParagraph paragraph, String textToFind, String replacement) {         TextSegment foundTextSegment = null;         PositionInParagraph startPos = new PositionInParagraph(0, 0, 0);         while ((foundTextSegment = searchTextExt(paragraph, textToFind, startPos)) != null) { \/\/ search all text segments having text to find              \/\/ maybe there is text before<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-443749","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/443749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=443749"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/443749\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=443749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=443749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=443749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}