Jon*_*Lam 1 python powerpoint python-3.x python-pptx
我正在使用 pptx python 创建一个表
参考:https : //python-pptx.readthedocs.io/en/latest/dev/analysis/tbl-table.html
创建表格时,我获得了默认表格样式,我想更改它。有什么推荐吗?
x, y, cx, cy = Inches(4.5), Inches(1.5), Inches(4.0), Inches(0)
shape = slide.shapes.add_table(7, 5, x, y, cx, cy)
table = shape.table
Run Code Online (Sandbox Code Playgroud)
我在想,table.apply_style()但我无法弄清楚正确的语法
好的找到了解决方案
x, y, cx, cy = Inches(4.5), Inches(1.5), Inches(4.0), Inches(0)
shape = slide.shapes.add_table(7, 5, x, y, cx, cy)
table = shape.table
tbl = shape._element.graphic.graphicData.tbl
style_id = '{1FECB4D8-DB02-4DC6-A0A2-4F2EBAE1DC90}'
tbl[0][-1].text = style_id
Run Code Online (Sandbox Code Playgroud)
我正在使用 Medium Style 1 Accent 3,替换为sytle_id在此列表中找到的 GUI:https : //github.com/scanny/python-pptx/issues/27#issuecomment-263076372