使用Python-Docx设置字体属性

时间:2021-02-25 19:20:26

I am creating a word document programmatically using the Python-docx module.

我正在使用Python-docx模块以编程方式创建word文档。

I want to be able to center my headers, turn certain words to bold in a table I create, and do other basic mark up.

我希望能够将我的标题集中,在我创建的表格中将某些单词转换为粗体,并进行其他基本标记。

Unfortunately, reading over the source code in the module doesn't give me much of a lead on doing this.

不幸的是,阅读模块中的源代码并没有给我带来很大的帮助。

I'm guessing it has something to do with the lxml/etree module that the docx code is based upon, but I don't have much familiarity with that library. Any ideas?

我猜它与docx代码所基于的lxml / etree模块有关,但我对该库并不太熟悉。有任何想法吗?

1 个解决方案

#1


0  

The link above points to the legacy repository for python-docx. The new one (v0.3.0 and later) is a complete rewrite and is located here: https://github.com/python-openxml/python-docx

上面的链接指向python-docx的遗留存储库。新的(v0.3.0及更高版本)是一个完整的重写,位于:https://github.com/python-openxml/python-docx

All the features listed above are available in the current version.

上面列出的所有功能都在当前版本中提供。

The documentation is here: https://python-docx.readthedocs.org/en/latest/

文档在这里:https://python-docx.readthedocs.org/en/latest/

Only bug fixes are being done on the legacy version, to support projects that still use it.

只对遗留版本进行了错误修复,以支持仍在使用它的项目。

The python-docx SO tag is monitored and questions tagged with that usually get answered same day now.

python-docx SO标签受到监控,标记的问题通常会在同一天得到回复。

#1


0  

The link above points to the legacy repository for python-docx. The new one (v0.3.0 and later) is a complete rewrite and is located here: https://github.com/python-openxml/python-docx

上面的链接指向python-docx的遗留存储库。新的(v0.3.0及更高版本)是一个完整的重写,位于:https://github.com/python-openxml/python-docx

All the features listed above are available in the current version.

上面列出的所有功能都在当前版本中提供。

The documentation is here: https://python-docx.readthedocs.org/en/latest/

文档在这里:https://python-docx.readthedocs.org/en/latest/

Only bug fixes are being done on the legacy version, to support projects that still use it.

只对遗留版本进行了错误修复,以支持仍在使用它的项目。

The python-docx SO tag is monitored and questions tagged with that usually get answered same day now.

python-docx SO标签受到监控,标记的问题通常会在同一天得到回复。