[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.ICustomXmlPartCollection

ICustomXmlPartCollection Interface

Represents a collection of Custom XML parts in a workbook.

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.

Namespace: GrapeCity.Documents.Excel
Assembly: DS.Documents.Excel.dll
Syntax
public interface ICustomXmlPartCollection : IEnumerable<ICustomXmlPart>, IEnumerable
Public Interface ICustomXmlPartCollection
    Inherits IEnumerable(Of ICustomXmlPart), IEnumerable
Examples
ICustomXmlPartCollection customXmlParts = workbook.CustomXmlParts;
ICustomXmlPart customXmlPart = customXmlParts.Add();
customXmlPart.Data = System.Text.Encoding.UTF8.GetBytes("<payload><value>42</value></payload>");

string id = customXmlPart.Id;
ICustomXmlPart partById = customXmlParts[id];
ICustomXmlPart firstPart = customXmlParts[0];
int count = customXmlParts.Count;

Properties

Name Description
Count

Gets the number of Custom XML parts in the collection.

this[int]

Gets the Custom XML part at the specified zero-based index.

Use the index to enumerate or access parts in collection order. If the index is outside the valid range, an ArgumentOutOfRangeException is thrown.

this[string]

Gets the Custom XML part with the specified ID.

The ID is the value returned by Id. This lookup is useful after a workbook is reopened or when multiple Custom XML parts are stored in the same workbook.

Methods

Name Description
Add()

Adds a new Custom XML part.

The new part receives a generated ID. Set the XML payload by using Data before saving the workbook.

Remove(int)

Removes the Custom XML part at the specified zero-based index.

If the index is outside the valid range, the collection is not changed.

Remove(string)

Removes the Custom XML part with the specified ID.

If no part with the specified ID exists, the collection is not changed.