Python-pptx图表修复错误

时间:2018-06-22 19:03:36

标签: python-2.7 powerpoint python-pptx

所以我有一个现有的PowerPoint,其中有一个要编辑的图表。

我只是想弄清楚如何更新图表,因此,我直接从pptx api使用代码:

slide = prs.slides[1]
for shape in slide.shapes:
  if not shape.has_text_frame:
    if shape.has_chart:
        chart = shape.chart
        print ' found a chart'    #this line prints        
        chart_data = ChartData()
        chart_data.categories = 'Foobar', 'Barbaz', 'Bazfoo'
        chart_data.add_series('New Series 1', (5.6, 6.7, 7.8))
        chart_data.add_series('New Series 2', (2.3, 3.4, 4.5))
        chart_data.add_series('New Series 3', (8.9, 9.1, 1.2))
        chart.replace_data(chart_data)

此代码运行良好,但是当我打开输出文档时,出现一个对话框:PowerPoint在[new_file_name.pptx]中发现内容问题。 Powerpoint可以尝试修复演示文稿。如果您信任此演示文稿的来源,请单击“修复”。

一旦我单击“修复”,幻灯片[1](我要更改其图表的幻灯片)上的所有内容将全部消失。

这似乎不正确,因为我使用的是api提供的确切代码。

有人可以帮忙吗?

0 个答案:

没有答案
相关问题