将图表添加到 WordprocessingML
我想使用 Open Xml SDK 2 生成一个包含图表的 Open XML 文档。 我找到了 SpreadsheetML 示例,但我不能不知道如何在 .docx 中添加图表...
是否有 Open Xml SDK 2 的文档/示例的良好来源?
I would like to generate an Open XML document containing a Chart using the Open Xml SDK 2.
I found an SpreadsheetML example, but I can't work out how to add the chart in a .docx...
Is there a good source for documentation/examples for the Open Xml SDK 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
本文从XML角度介绍如何向WordProcessingML添加图片:
http://openxmldeveloper.org/articles/462.aspx
使用相同内容的实际代码开放 XML API:
http://msdn.microsoft.com/en-us /library/bb497430(office.14).aspx
如果您已成功将图表添加到 SpreadsheetML,则可以调整图片示例以对 WordProcessingML 执行相同的操作。 您仍然会拥有他们示例中的 a:graphic 元素。 其中包含的 a:graphicData 将具有一个图表 URI (http://schemas.openxmlformats.org /drawingml/2006/chart)而不是图片 URI。 a:graphicData 中的数据将与 SpreadsheetML 中的数据相同。
This article describes how to add a picture to WordProcessingML from an XML perspective:
http://openxmldeveloper.org/articles/462.aspx
Actual code for the same thing using the Open XML API:
http://msdn.microsoft.com/en-us/library/bb497430(office.14).aspx
If you've successfully added a chart to SpreadsheetML, you can adapt the picture example to do the same for WordProcessingML. You'll still have the a:graphic element that they have in their example. Contained inside, the a:graphicData will have a chart URI (http://schemas.openxmlformats.org/drawingml/2006/chart) instead of a picture URI. The data inside the a:graphicData will be identical to what you had for SpreadsheetML.
我没有适合您的示例,但请查看 cfchunks:
https://blogs.msdn.com/johnrdurant/archive/2005/07/15/cfChunk.aspx
http://blogs.msdn.com/brian_jones/archive/2005/07/20/441167.aspx
I don't have an example for you, but look into cfchunks:
https://blogs.msdn.com/johnrdurant/archive/2005/07/15/cfChunk.aspx
http://blogs.msdn.com/brian_jones/archive/2005/07/20/441167.aspx
不幸的是,网上缺乏有效的例子。 与往常一样,使用 OpenXmlSDK 时最简单的方法是创建带有图表的 Word 文档并在文档资源管理器工具中打开它。
当我过去插入图表时,它们已作为文档中的“ChartPart”插入,该文档与数据源和格式有多个子部分关系,然后在文档正文本身中,“c:chartReference”引用了按 ID 划分的图表部分。 我相信图表参考位于图形数据下方。
Unfortunately there is a shortage of worked examples on the net. As always the simplest way when using the OpenXmlSDK is to create a word document with a chart and open it within the document explorer tool.
When I've inserted charts in the past they have been inserted as a "ChartPart" within the document, which had several child part relationships to the data source and formatting and then within the documnet Body itself a "c:chartReference" referred to the chart part by id. I believe the chartReference lives underneath a graphicData.