2017-06-19 164 views
1

我想从文档中使用此示例将行高设置为固定值。如何在python-docx中修复表格中的行高?

http://python-docx.readthedocs.io/en/latest/dev/analysis/features/table/table-row.html?highlight=table#row-height

(如果链路断开内容)

>>> 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' 

检查源,表.py文件存在,但只有WD_TABLE_ALIGNMENTWD_TABLE_DIRECTION英寸。

我的python-docx版本是0.8.6

回答

2

您提到的链接实际上是未来的功能(即,尚未实现)。

+0

这完美地回答了我的问题。如果有任何想法,它会*实施,这将是有益的,但我意识到可能没有。 –

相关问题