如何将 table 中的行高设置为固定在 python-docx 中?
How can I set row height in a table to be fixed in python-docx?
我正在尝试使用文档中的这个示例将行高设置为固定值。
(内容以防 link 中断)
>>> from docx.enum.table import WD_ROW_HEIGHT
>>> row = table.add_row()
>>> row
<docx.table._Row object at 0x...>
>>> row.height_rule
None
>>> row.height_rule = WD_ROW_HEIGHT.EXACTLY
>>> row.height
None
>>> row.height = Pt(24)
但是,我无法从 docx.enum.table
导入 WD_ROW_HEIGHT
,出现此错误:
Traceback (most recent call last):
File "C:/Users/Calderdale NUT/Google Drive/CDFU/Membership Python/labels test.py", line 2, in <module>
from docx.enum.table import WD_ROW_HEIGHT
ImportError: cannot import name 'WD_ROW_HEIGHT'
查看来源,table.py文件是存在的,但只有WD_TABLE_ALIGNMENT
和WD_TABLE_DIRECTION
在。
我的python-docx版本是0.8.6
您提到的link实际上是未来的功能(即尚未实现)。
我正在尝试使用文档中的这个示例将行高设置为固定值。
(内容以防 link 中断)
>>> from docx.enum.table import WD_ROW_HEIGHT
>>> row = table.add_row()
>>> row
<docx.table._Row object at 0x...>
>>> row.height_rule
None
>>> row.height_rule = WD_ROW_HEIGHT.EXACTLY
>>> row.height
None
>>> row.height = Pt(24)
但是,我无法从 docx.enum.table
导入 WD_ROW_HEIGHT
,出现此错误:
Traceback (most recent call last):
File "C:/Users/Calderdale NUT/Google Drive/CDFU/Membership Python/labels test.py", line 2, in <module>
from docx.enum.table import WD_ROW_HEIGHT
ImportError: cannot import name 'WD_ROW_HEIGHT'
查看来源,table.py文件是存在的,但只有WD_TABLE_ALIGNMENT
和WD_TABLE_DIRECTION
在。
我的python-docx版本是0.8.6
您提到的link实际上是未来的功能(即尚未实现)。