gpt4 book ai didi

python - 合并单元格在 Python PPTx 中不起作用

转载 作者:行者123 更新时间:2023-12-01 00:51:17 28 4
gpt4 key购买 nike

我的代码:

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 :)

关于python - 合并单元格在 Python PPTx 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56558334/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com