How to update different embebbed charts on Powerpoint with openxml?
I want to update various charts on openxml Powerpoint file using openxml sdk 2. I have managed to update the data on the excel sheet that feeds the chart and the chart itself. but that's not very e开发者_JAVA百科fficient because i end up doing the same thing twice (updating the embedded excel and the chart object with the same data) and also because the chart object's xml structure is different for different chart types, so more should-be-unnecessary code and probably more bugs. I wonder if there is a way to tell the Chart to update itself with the new data on the excel. I also tried to use the AutoUpdate property of the chart but without any results. This is a follow up question. The first one was this one: How to make a powerpoint chart reflect changes to its data source?
To my knowledge, what you are looking for (frustrating as it is) is not possible. I've been in the exact same position with word documents, and ended up doing a method for each type of chart I knew my code would encounter.
I don't believe there is a trigger for you to force an update upon opening word.
But I would love to be proved wrong.
Editing to clarify. Yes, you can update the charts by only updating the data-caches in xml and not the embedded parts, however, you then end up with a word document in which, if you double click a chart to vidw the data-source, you'll get another data-source than the one shown in the document. Further more, when you close the data-source (the embedded excel) the chart will update to the values from the embedding.
In short. Unless you intend to PDF your document or something like that, it is advicable to update both the embeddings and the xml-charts.
精彩评论