Hello fellow developers,
Being a newbie with the OpenXML SDK I cannot figure out how to retrieve a graph part that I've put in a rich text control (with a specific tag name).
For the moment I retrieve the graph part by using the mainDocumentPart.ChartParts collection. But a ChartPart object does not seem to know where it's located in the document: chartPart.GetParentParts() only contains the mainDocumentPart.
I have multiple graphs in my document, so how can I distinguish them? I have put my graphs in rich text controls, so I thought I could access them like that, but I cannot figure out how to do this. Retrieving the rich text control works, but how to find the graph within it?
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
}
}
}
Thanks a lot for your help.