Python-docx,单元格中的垂直对齐

时间:2017-03-28 15:48:29

标签: ms-word python-docx

是否可以垂直对齐文本,使其在表格单元格中垂直居中?

2 个答案:

答案 0 :(得分:0)

 Tablename.Rows(0).Cells(0).VerticalAlignment = VerticalAlignment.Center

答案 1 :(得分:0)

from docx.enum.table import WD_ALIGN_VERTICAL

table = document.add_table(3, 3)
table.cell(0, 0).vertical_alignment = WD_ALIGN_VERTICAL.BOTTOM

https://python-docx.readthedocs.io/en/latest/api/enum/WdCellVerticalAlignment.html