簡體   English   中英

如何設置要在python-docx中固定的表中的行高?

[英]How can I set row height in a table to be fixed in 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_HEIGHTdocx.enum.table此錯誤:

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_ALIGNMENTWD_TABLE_DIRECTION

我的python-docx版本是0.8.6

您引用的鏈接實際上是將來的功能(即尚未實現)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM