1
votes

There is an excel file with different sheets which is included by different charts and data.enter image description here I want to make a powerpoint for my daily presentation automatically by python(PPTx lib in python).

my problem is I have to copy the charts which exist in excel and past in my powerpoint which is created by python (pptx). I want to know is there any possibility to export charts from excel file to powerpoint by python?

1

1 Answers

2
votes

There is no direct API support for this in python-pptx. However, there are other approaches that might work for you.

Perhaps the simplest would be to use a package like openpyxl to read the data from the spreadsheet and recreate the chart using python-pptx, based on the data read from Excel.

If you wanted to copy the chart exactly, this is also possible but would require detailed knowledge of the Open Packaging Convention (OPC) file format and XML schemas to accomplish. Essentially, you would copy the chart-part for the chart into the PowerPoint package (zip file) and connect it to a graphic-frame shape on a slide. You'd also need to embed the Excel worksheet into the PowerPoint, perhaps repeatedly (once for each chart) and make any format-specific adjustments (Excel and PowerPoint handle charts slightly differently in certain details).

This latter approach would be a big job, so I would recommend trying the simpler approach first and see if that will get it done for you.