【发布时间】:2013-05-29 10:14:43
【问题描述】:
各位开发者您好,
作为 OpenXML SDK 的新手,我不知道如何检索已放入富文本控件(具有特定标签名称)的图形部分。
目前,我使用 mainDocumentPart.ChartParts 集合检索图形部分。但是 ChartPart 对象似乎不知道它在文档中的位置:chartPart.GetParentParts() 只包含 mainDocumentPart。
我的文档中有多个图表,如何区分它们? 我已经将我的图表放在富文本控件中,所以我认为我可以像那样访问它们,但我不知道如何做到这一点。检索富文本控件有效,但如何在其中找到图形?
foreach (SdtProperties sdtProp in mainDocumentPart.Document.Body.Descendants<SdtProperties>())
{
Tag tag = sdtProp.GetFirstChild<Tag>();
if (tag != null && tag.Val != null)
{
if (tag.Val == "containerX")
{
SdtProperties sdtPropTestResults = sdtProp;
// How to retrieve the graph part??
// sdtPropTestResults.Descendants<ChartPart> does not seem to work
}
}
}
非常感谢您的帮助。
【问题讨论】:
标签: c# openxml-sdk