如何使用python pptx查找幻灯片上的所有图表?

问题描述

假设我在 PowerPoint 幻灯片上有 4 个图表。我可以操作其中一个图表,但不知道如何访问其他三个图表。

prs = Presentation(presentation_path)
graphic_frame = prs.slides[2].shapes
chart = graphic_frame[0].chart

plot = chart.plots[0]
category_labels = [c.label for c in plot.categories]
series = plot.series[0]
print(category_labels)
print(series.name)
print(series.values)

md = {}
for i in range(0,len(plot.series)):
    md[plot.series[i].name] = list(plot.series[i].values)

chart_data = CategoryChartData()
chart_data.categories = [c.label for c in plot.categories]

for key,value in md.items():
    chart_data.add_series(key,[10*v for v in value])

chart.replace_data(chart_data)

prs.save(path_to_save_presentation)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)