首页 > 解决方案 > python-docx - 在文档末尾添加一个表格

问题描述

我必须在每个文档的末尾添加一个表格。但是文本永远不会在文档末尾完成。

是否有任何提示如何在文档末尾附加此表?谢谢

txt = ["xxxxxx","yyyyyy","zzzzzz"]
d = Document(os.path.join(path,i))
table = d.add_table(rows=3, cols=1)
for j in range(3):
    row = table.rows[j]
    row.cells[0].text = txt[j]
d.save(os.path.join(path,i))

输出: 在此处输入图像描述

标签: pythonpython-docx

解决方案


推荐阅读