scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.35k stars 510 forks source link

Replaced chart data while opening repair error #808

Open ramesh3099 opened 2 years ago

ramesh3099 commented 2 years ago

prs = Presentation('onechart.pptx') slide = prs.slides[1] for shape in slide.shapes: if shape.shape_id == 286: chart=shape.chart chart_data = CategoryChartData() chart_data.categories = ['2017', '2018', '2019','2020','2021'] chart_data.add_series('Series 1', (198.0, 80.0, 70.0, 577.0, 1420.0)) chart_data.add_series('Series 2', (98.0, 180.0, 170.0, 77.0, 3420.0)) chart_data.add_series('Series 3', (298.0, 480.0, 270.0, 277.0, 4220.0)) chart_data.add_series('Series 4', (198.0, 80.0, 70.0, 577.0, 5420.0)) chart_data.add_series('Series 5', (98.0, 180.0, 170.0, 77.0, 6420.0)) chart_data.add_series('Series 6', (298.0, 480.0, 270.0, 277.0, 7220.0)) chart.replace_data(chart_data)

prs.save("sample0.pptx")

I Am trying to replace existed chart data for that i wrote above code and executed while execution there is no error file also created , When i am trying to open file it is showing one dialogue box that says: PowerPoint found a problem with the content in [new_file_name.pptx]. Powerpoint can attempt to repair the presentation. If you trust the source of this presentation, click Repair.

Once I click "Repair", all the contents on slide[1] (the slide I'm changing the chart of) is completely gone.

@scanny please help me

Is there any wrong in my code .

mszbot commented 2 years ago

Ask this question on stackoverflow.

veljanin commented 1 year ago

I'm facing the same issue but it seems this only happens with the stacked charts on mine end.