合并单元格在 Python PPTx 中不起作用
Merging of cell not working in Python PPTx
我的代码:
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' object has no attribute 'merge'
Python - 3.5.x
任何有关此错误原因的帮助!!
此功能是最近添加的(v0.6.14,2018-09-24)。
检查你的 python-pptx
版本,我想你需要一个 pip install -U python-pptx
:)
我的代码:
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' object has no attribute 'merge'
Python - 3.5.x
任何有关此错误原因的帮助!!
此功能是最近添加的(v0.6.14,2018-09-24)。
检查你的 python-pptx
版本,我想你需要一个 pip install -U python-pptx
:)