更新使用Apache POI .docx文件的页头 [英] Updating a .docx file's page header using Apache POI
问题描述
我如何更新使用Apache POI 3.7 API一个 .DOCX
文件的页头?
How can I update the page header of a .docx
file using the Apache POI 3.7 API?
推荐答案
首先,请致电<一个href=\"http://poi.apache.org/apidocs/org/apache/poi/xwpf/usermodel/XWPFDocument.html#getHeaderFooterPolicy%28%29\"相对=nofollow> getHeaderFooterPolicy()在你的XWPFDocument ,它返回的 HeaderFooterPolicy 。从这一点,你可以找出适当的头为你的页面(如默认情况下,第一页等)
First up, call getHeaderFooterPolicy() on your XWPFDocument, which returns a HeaderFooterPolicy. From that, you can identify the appropriate header for your page (eg Default, First Page etc)
一旦有适当的 XWPFHeader 要改变,那么你可以去修改它的任何其他文件的一部分。你可以取表,段落等,然后将其删除,添加新的,改变他们文字等。这都是相同的进程那么作为编辑主文档。
Once you have the appropriate XWPFHeader that you want to change, then you can go about editing it as any other document part. You can fetch the tables, the paragraphs etc, then remove them, add new ones, change the text of them etc. It's all the same process then as editing the main document.
这篇关于更新使用Apache POI .docx文件的页头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!