0

我正在尝试在 Word 中使用 制作表格python-docx,但在创建表格并保存文件后,表格没有任何行/分隔符。所以我尝试使用 table.style 选项,但我无法使用任何样式,除了Normal Table(这是默认设置)。

这是我用来创建表的代码:

import docx

file = docx.Document()
table = file.add_table(6, 4)

fRow = table.rows[0]
fRow[0].text = "some headline"
... 
table.style = "<stylename here>" 

file.save("test.docx")

我尝试的所有样式都来自这个网站: https ://python-docx.readthedocs.io/en/latest/user/styles-understanding.html#built-in-styles

我在 Windows 11 上使用 Python 3.10.0b4。

4

0 回答 0