from docx import Document
document = Document()
r = 2 # Number of rows you want
c = 2 # Number of collumns you want
table = document.add_table(rows=r, cols=c)
table.style = 'LightShading-Accent1' # set your style, look at the help documentation for more help
for y in range(r):
for x in range(c):
cell.text = 'text goes here'
document.save('demo.docx') # Save document
签出this project
和here is a great quick-start guide
使用起来很简单,我还没有测试过,但应该可以:
它不认为您可以用这个库设置页面方向属性,但是您可以做的是创建一个空白的word文档,该文档位于scape中,将其存储在工作目录中,并在每次生成此文档时复制它。
相关问题 更多 >
编程相关推荐