ICustomXmlPart Interface
A custom XML part embedded in a workbook.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
public interface ICustomXmlPart :
OfficeCustomXmlPart<ICustomXmlPart>,
OfficeCustomXmlPart
Remarks
You can embed arbitrary XML data (called custom XML parts) in a workbook. Custom XML parts are included in the document structure but are not visible in the document.
The image below shows the structure of an XLSX file with three custom XML parts (item1, item2, and item3).
The following spreadsheet file formats support custom XML parts:
- XLSX;
- XLSM;
- XLTX;
- XLTM;
- XLSB;
- XLS;
- XLT.
A custom XML part is an object that exposes the ICustomXmlPart interface. Use one of the following properties to access the CustomXmlPartCollection collection that stores custom XML parts:
-
Returns the collection of custom XML parts for a non-visual Workbook.
-
Returns the collection of custom XML parts for the SpreadsheetControl‘s document.
You can use a custom XML part’s index to obtain it from the collection. Use the CustomXmlPartDocument property to access an XML document associated with the ICustomXmlPart object.
using DevExpress.Spreadsheet;
using System.Xml;
// ...
using (Workbook workbook = new Workbook())
{
// Load a document.
workbook.LoadDocument("Documents\\CustomXml.xlsx");
// Access a custom XML file stored in the document.
XmlDocument xmlDoc = workbook.CustomXmlParts[0].CustomXmlPartDocument;
// Retrieve a reference to a fish that belongs to a specific category.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
string xPathString = "//Fish[Category='Cod']/ScientificClassification/Reference";
XmlNode xmlNode = xmlDoc.DocumentElement.SelectSingleNode(xPathString, nsmgr);
string hLink = xmlNode.InnerText;
// Display the obtained value in a cell as a hyperlink.
workbook.Worksheets[0].Hyperlinks.Add(workbook.Worksheets[0].Cells["A2"], hLink, true);
}