合并在Python PPTx中不工作的单元格

2024-04-25 12:30:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码

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版

任何关于为什么这个错误的帮助!!你知道吗


Tags: pathdftitletablecellframestartplaceholder
1条回答
网友
1楼 · 发布于 2024-04-25 12:30:21

此功能是最近添加的(v0.6.14,2018-09-24)。你知道吗

检查你的python-pptx版本,我想你需要一个pip install -U python-pptx:)

相关问题 更多 >

    热门问题