2017-06-19 96 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

這完美地回答了我的問題。如果有任何想法,它會*實施,這將是有益的,但我意識到可能沒有。 –

相關問題