且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在poi word中设置目录的字体样式,包括字体颜色、字体大小和粗体?

更新时间:2021-10-27 22:26:49

您的很多问题似乎都与 XWPF 有关.这是一个不完整的 API.您可以阅读规范来确定如何做 API 中没有出现的事情,然后可能将其回馈给社区.规范位于此处.Apache POI 项目使用第一版模式.我发现第 1、3 和 4 部分最有用.

A lot of your questions seem to be about XWPF. This is an incomplete API. You could read the spec to determine how to do things not surfaced in the API, and then potentially donate it back to the community. The specs are here. The Apache POI project uses the first edition schema. I find that Parts 1, 3, and 4 are the most useful.

至于这个具体问题,您是否通过 doc.createTOC() 获得了您想要的结果?你得到什么?它是否位于文档中的适当位置?在 SO 上还有其他关于 TOC 的问题.这个特别有用.如果您需要其他行为,上面提到的规范包含更多 TOC 字段的开关,例如要包含的自定义标题样式.可以通过修改适当的 TOCx 样式来设置 TOC 级别的样式,其中 x 是 TOC 级别.

As to this specific question, are you getting what you want with doc.createTOC()? What are you getting? Is it located in the appropriate place in the document? There are other questions concerning TOC here on SO. This one in particular may help. If you need additional behaviors, the specs mentioned above contain more switches for the TOC field such as custom header styles to be included. The style of the TOC levels can be set by modifying the appropriate TOCx style where x is the TOC level.