小编gir*_*eux的帖子

Python-docx,如何在表中设置单元格宽度?

如何在表格中设置单元格宽度?到目前为止,我得到了:

from docx import Document
from docx.shared import Cm, Inches

document = Document()
table = document.add_table(rows=2, cols=2)
table.style = 'TableGrid' #single lines in all cells
table.autofit = False

col = table.columns[0] 
col.width=Inches(0.5)
#col.width=Cm(1.0)
#col.width=360000 #=1cm

document.save('test.docx')
Run Code Online (Sandbox Code Playgroud)

没有我在col.width中设置的数量或单位,其宽度不会改变.

ms-word column-width python-docx

13
推荐指数
2
解决办法
1万
查看次数

标签 统计

column-width ×1

ms-word ×1

python-docx ×1