[]
Iterable<ICustomXmlPart>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.
ICustomXmlPartCollection customXmlParts = workbook.getCustomXmlParts();
ICustomXmlPart customXmlPart = customXmlParts.add();
customXmlPart.setData("<payload><value>42</value></payload>"
.getBytes(java.nio.charset.StandardCharsets.UTF_8));
String id = customXmlPart.getId();
ICustomXmlPart partById = customXmlParts.get(id);
ICustomXmlPart firstPart = customXmlParts.get(0);
int count = customXmlParts.getCount();
add()get(int index) intgetCount()voidremove(int index) voidforEach, iterator, spliteratorThe new part receives a generated ID. Set the XML payload by using ICustomXmlPart.setData(byte[]) before saving the workbook.
ICustomXmlPart customXmlPart = workbook.getCustomXmlParts().add();
customXmlPart.setData("<customer id=\"42\"/>"
.getBytes(java.nio.charset.StandardCharsets.UTF_8));
String id = customXmlPart.getId();
The ID is the value returned by ICustomXmlPart.getId(). This lookup is useful after a workbook is reopened or when multiple Custom XML parts are stored in the same workbook.
ICustomXmlPart customXmlPart = workbook.getCustomXmlParts().add();
String id = customXmlPart.getId();
ICustomXmlPart samePart = workbook.getCustomXmlParts().get(id);
id - The ID of the Custom XML part.null if it is not found.Use the index to enumerate or access parts in collection order. If the index is outside the valid range, an IndexOutOfBoundsException is thrown.
if (workbook.getCustomXmlParts().getCount() > 0) {
ICustomXmlPart firstPart = workbook.getCustomXmlParts().get(0);
byte[] xmlData = firstPart.getData();
}
index - The zero-based index of the Custom XML part.If no part with the specified ID exists, the collection is not changed.
ICustomXmlPart customXmlPart = workbook.getCustomXmlParts().add();
String id = customXmlPart.getId();
workbook.getCustomXmlParts().remove(id);
id - The ID of the Custom XML part to remove.If the index is outside the valid range, the collection is not changed.
if (workbook.getCustomXmlParts().getCount() > 0) {
workbook.getCustomXmlParts().remove(0);
}
index - The zero-based index of the Custom XML part to remove.
int count = workbook.getCustomXmlParts().getCount();
for (int i = 0; i < count; i++) {
ICustomXmlPart customXmlPart = workbook.getCustomXmlParts().get(i);
}