.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Workbook.CustomXmlParts Property

Provides access to a workbook’s collection of custom XML parts.

You need an active license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this property in production code.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v21.2.dll


public CustomXmlPartCollection CustomXmlParts { get; }

Property Value

Type Description

A collection of custom XML parts.


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.

The Workbook.CustomXmlParts property provides access to the CustomXmlPartCollection collection that stores custom XML parts. Use the collection’s members to insert, obtain, modify, or remove custom XML parts.

The example below shows how to add custom XML parts to a workbook.

using DevExpress.Spreadsheet;
using System.Xml;
// ...

using (Workbook workbook = new Workbook())
   workbook.Worksheets[0].Cells["A1"].Value = "This workbook contains custom XML parts.";

   // Add an empty custom XML part.
   ICustomXmlPart xmlItem = workbook.CustomXmlParts.Add();
   // Populate the XML part with content.
   XmlElement elem = xmlItem.CustomXmlPartDocument.CreateElement("Person");
   elem.InnerText = "Stephen Edwards";

   // Use a string to specify the content for a custom XML part.
   string xmlString = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                                 <address>1657 Wines Lane Houston, TX 77099</address>
   workbook.CustomXmlParts.Insert(1, xmlString);

   // Add a custom XML part from a file.
   XmlDocument xmlDoc = new XmlDocument();
   workbook.SaveDocument("Documents\\CustomXmlTestDoc.xlsx", DocumentFormat.Xlsx);


See Also