用python填充Tableplaceholder

时间:2019-07-11 15:31:02

标签: python pandas powerpoint placeholder

我想借助python将我的tableplaceholder填充到powerpoint中。但我的代码无法正常工作:

from pptx import Presentation

prs = Presentation("Test.pptx")
slide = prs.slides.add_slide(prs.slide_layouts[0])
for shape in slide.placeholders:    
    print('%d %s' % (shape.placeholder_format.idx, shape.name))
​
--> 13 Table Placeholder 1
prs = Presentation('Test.pptx')
​
​slide = prs.slides.add_slide(prs.slide_layouts[1])
placeholder = slide.placeholders[13]  # idx key, not position
placeholder.name
--> 'Table Placeholder 1'
placeholder.placeholder_format.type
--> 12
graphic_frame = placeholder.insert_table(rows=2, cols=2)
table = graphic_frame.table
len(table.rows), len(table.columns)
--> (2, 2)

0 个答案:

没有答案