python docx中的列宽调整

时间:2018-01-26 14:16:25

标签: python python-docx

我正在使用python docx。我想调整列宽。它在我的代码中以纵向模式工作。但是,当我将页面方向更改为横向时,它对我不起作用。

document.add_page_break()
new_section = document.add_section(WD_SECTION.ODD_PAGE)
new_section.orientation = WD_ORIENT.LANDSCAPE
new_section.page_width  = Inches(11.7)
new_section.page_height = Inches(8.3)
document.add_heading('Multiple Setter', level=1)
table = document.add_table(rows=1, cols=5)
table.allow_autofit = False
table.alignment = WD_TABLE_ALIGNMENT.LEFT
table.style = "Table Grid"
hdr_cells = table.rows[0].cells
hdr_cells[0].width = Cm(4)
hdr_cells[0].text = 'Variable'
hdr_cells[1].width = Cm(5)
hdr_cells[1].text = 'Function Writing'
你可以指导我什么不对吗?

0 个答案:

没有答案