Defines the custom XML part embedded in a workbook.
A document in OpenXml (.xlsx) format consists of XML files within folders packed in a ZIP archive. Most of the XML files are built-in parts that define the document structure and hold its content. However, documents can also contain custom XML parts, which you can use to store arbitrary XML data.
A custom XML part is an object that exposes the ICustomXmlPart interface. All custom XML parts are contained in the CustomXmlPartCollection collection accessible using the IWorkbook.CustomXmlParts property.
This code snippet demonstrates how to use XPath query to obtain information from the document's custom XML part.
The custom XML part is accessed by its index in the IWorkbook.CustomXmlParts collection. The XML document contained in a custom XML part is available using the ICustomXmlPart.CustomXmlPartDocument property. To find the specified XML node, the XPath query is supplied to the SelectSingleNode method of the XmlDocument object. The obtained string is inserted into the active worksheet as a Hyperlink.
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheetcontrol-api-part-3-t231273
workbook.LoadDocument("Documents\\CustomXml.xlsx"); XmlDocument xmlDoc = workbook.CustomXmlParts.CustomXmlPartDocument; XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable); string xPathString = "//Fish[Category='Cod']/ScientificClassification/Reference"; XmlNode xmlNode = xmlDoc.DocumentElement.SelectSingleNode(xPathString, nsmgr); string hLink = xmlNode.InnerText; workbook.Worksheets.Hyperlinks.Add(workbook.Worksheets.Cells["A2"], hLink, true);