我的代码:
path =r"Sample PPT.pptx"
prs = Presentation(path)
title_slide_layout = prs.slide_layouts[3]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
title.text = "Summary Table"
shapes = slide.shapes
""" Putting the table in placeholder"""
placeholder = slide.placeholders[13]
graphic_frame = placeholder.insert_table(rows=df.shape[0]+2, cols=df.shape[1])
table = graphic_frame.table
"""Merging cells and naming them """
start_cell = table.cell(0, 0)
end_cell = table.cell(1,1)
start_cell.merge(end_cell)
错误:
AttributeError:'_Cell'对象没有属性'merge'
Python-3.5.x
有关此错误原因的任何帮助!
答案 0 :(得分:2)
此功能是最近才添加的(v0.6.14,2018-09-24)。
检查您的python-pptx
版本,我希望您需要pip install -U python-pptx
:)