如何使用 openxml 更新 Powerpoint 上的不同嵌入图表?
我想使用 openxml sdk 2 更新 openxml Powerpoint 文件上的各种图表。 我已经成功更新了为图表提供数据的 Excel 工作表和图表本身。但这不是很有效,因为我最终做了两次相同的事情(使用相同的数据更新嵌入的 Excel 和图表对象),而且还因为图表对象的 xml 结构对于不同的图表类型是不同的,所以更多应该是不必要的代码和可能更多的错误。 我想知道是否有一种方法可以告诉图表使用 Excel 上的新数据进行自我更新。 我还尝试使用图表的 AutoUpdate 属性,但没有任何结果。这是一个后续问题。第一个是这个:如何使 Powerpoint 图表反映其数据源的更改?
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 efficient 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您正在寻找的东西(尽管令人沮丧)是不可能的。
我在处理 Word 文档时也处于完全相同的位置,最终为我知道我的代码会遇到的每种类型的图表执行了一种方法。
我不相信您会在打开单词时触发强制更新。
但我很乐意被证明是错误的。
编辑以澄清。
是的,您可以通过仅更新 xml 中的数据缓存而不更新嵌入部分来更新图表,但是,您最终会得到一个 Word 文档,如果您双击图表来查看数据源,您将得到一个 Word 文档。将获得除文档中显示的数据源之外的另一个数据源。此外,当您关闭数据源(嵌入的 Excel)时,图表将更新为嵌入中的值。
简而言之。除非您打算将文档或类似的内容转换为 PDF 格式,否则建议更新嵌入和 xml 图表。
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.