# GrapeCity.Documents.Excel.ICustomXmlPartCollection

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="GrapeCity_Documents_Excel_ICustomXmlPartCollection" data-uid="GrapeCity.Documents.Excel.ICustomXmlPartCollection" class="text-break">ICustomXmlPartCollection Interface
</h1>
  <div class="markdown level0 summary"><p>Represents a collection of Custom XML parts in a workbook.</p>
<p>
Use this collection to add, retrieve, enumerate, or remove workbook-level Custom XML parts.
Each part has a generated ID and a raw XML payload. The collection is persisted when the workbook
is saved to an OpenXML workbook format such as XLSX or XLSM.
</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <h6><strong>Namespace</strong>: <a class="xref" href="GrapeCity.Documents.Excel.html">GrapeCity.Documents.Excel</a></h6>
  <h6><strong>Assembly</strong>: DS.Documents.Excel.dll</h6>
  <h5 id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public interface ICustomXmlPartCollection : IEnumerable&lt;ICustomXmlPart&gt;, IEnumerable</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Interface ICustomXmlPartCollection
    Inherits IEnumerable(Of ICustomXmlPart), IEnumerable</code></pre>
  </div>
  <h5 id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_examples"><strong>Examples</strong></h5>
  <pre><code class="lang-csharp">ICustomXmlPartCollection customXmlParts = workbook.CustomXmlParts;
ICustomXmlPart customXmlPart = customXmlParts.Add();
customXmlPart.Data = System.Text.Encoding.UTF8.GetBytes("&lt;payload&gt;&lt;value&gt;42&lt;/value&gt;&lt;/payload&gt;");

string id = customXmlPart.Id;
ICustomXmlPart partById = customXmlParts[id];
ICustomXmlPart firstPart = customXmlParts[0];
int count = customXmlParts.Count;</code></pre>

  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_Count" data-uid="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Count">
          <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Count.html#GrapeCity_Documents_Excel_ICustomXmlPartCollection_Count">Count</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the number of Custom XML parts in the collection.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_Item_System_Int32_" data-uid="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Item(System.Int32)">
          <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Item.html#GrapeCity_Documents_Excel_ICustomXmlPartCollection_Item_System_Int32_">this[int]</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the Custom XML part at the specified zero-based index.</p>
<p>
Use the index to enumerate or access parts in collection order. If the index is outside the
valid range, an <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception">ArgumentOutOfRangeException</a> is thrown.
</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_Item_System_String_" data-uid="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Item(System.String)">
          <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Item.html#GrapeCity_Documents_Excel_ICustomXmlPartCollection_Item_System_String_">this[string]</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the Custom XML part with the specified ID.</p>
<p>
The ID is the value returned by <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPart.Id.html#GrapeCity_Documents_Excel_ICustomXmlPart_Id">Id</a>. This lookup is useful after
a workbook is reopened or when multiple Custom XML parts are stored in the same workbook.
</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_Add" data-uid="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Add">
          <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Add.html#GrapeCity_Documents_Excel_ICustomXmlPartCollection_Add">Add()</a>
        </td>
        <td class="markdown level1 summary"><p>Adds a new Custom XML part.</p>
<p>
The new part receives a generated ID. Set the XML payload by using <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPart.Data.html#GrapeCity_Documents_Excel_ICustomXmlPart_Data">Data</a>
before saving the workbook.
</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_Remove_System_Int32_" data-uid="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Remove(System.Int32)">
          <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Remove.html#GrapeCity_Documents_Excel_ICustomXmlPartCollection_Remove_System_Int32_">Remove(int)</a>
        </td>
        <td class="markdown level1 summary"><p>Removes the Custom XML part at the specified zero-based index.</p>
<p>
If the index is outside the valid range, the collection is not changed.
</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Excel_ICustomXmlPartCollection_Remove_System_String_" data-uid="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Remove(System.String)">
          <a class="xref" href="GrapeCity.Documents.Excel.ICustomXmlPartCollection.Remove.html#GrapeCity_Documents_Excel_ICustomXmlPartCollection_Remove_System_String_">Remove(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Removes the Custom XML part with the specified ID.</p>
<p>
If no part with the specified ID exists, the collection is not changed.
</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
