scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.49k stars 534 forks source link

How to get refresh the showing of picture or chart when I updated the embedded excel data? #381

Open godisotaku opened 6 years ago

godisotaku commented 6 years ago

Hi Steve,

Would you like to help me for this problem? Thank you very much

Problem: I use xlsx_part.blob to read data from embedded excel from pptx file, and trans it into pd.dataframe, and update some data, and finally write it into embedded excel by xlsx_part.blob in pptx file.

The result data in excel is correct. But the showing of picture in pptx file correspondingly is wrong.

When I click on the chart in ppt slide, open the data in excel, close the excel, then I got the correct showing of picture in pptx slide.

It seems like it doesn't get refresh at once.

Please help me that how to get refresh the showing immediately after I updated the data of embedded excel.

Thank you

Jha-abhishek2019 commented 6 years ago

Hi, facing same issue,will appreciate if anyone could help.

scanny commented 6 years ago

This is due to a behavior of PowerPoint, that it doesn't refresh chart data on chart open. Rather it uses the values cached in the chart.xml file (e.g. chart2.xml) to render the chart.

If you want the behavior you're asking for, you'll need to hack a bit further and update those values as well.

You'd be on your own for that work, but as far as pointers, I'd take a close look at the Chart.replace_data() method and see if I could make that work or adapt it.

Maybe you could replace the data with your new values using a suitably loaded ChartData object, and the update then Xlsx blob after that.

deb-dasit commented 4 years ago

I want to hide some legends in a chart. Can anyone give me suggest me how to proceed.

Ov-ille commented 3 years ago

@godisotaku Could you go into some more detail how you write a pd.dataframe to the embedded excel behind a chart? I managed to read the xlsx_part.blob as a pd.dataframe but have no idea how to do it the other way round!

I use xlsx_part.blob to read data from embedded excel from pptx file, and trans it into pd.dataframe, and update some data, and finally write it into embedded excel by xlsx_part.blob in pptx file.