OpenXmlPackage.getPartsByRelationshipType (relationshipType)

Return to the
Open XML SDK for JavaScript
Developer Center
Gets an array of parts with the specified relationship type. openXml.relationshipTypes contains a list of the most common relationship types.

Syntax

    var parts = OpenXmlPackage.getPartsByRelationshipType(relationshipType);

Arguments

    relationshipType: An string that contains the relationship type.

Return Value

    Returns an array of OpenXmlPart objects. If there are no parts with the specified relationship type, this function returns a zero length array.

Usage

    var parts = doc.getPartsByRelationshipType(openXml.relationshipTypes.mainDocument);

Example

// Open a blank document that is stored as a base64 string.
var doc = new openXml.OpenXmlPackage(blankDocument_base64);
// Get the main document part.
var parts = doc.getPartsByRelationshipType(openXml.relationshipTypes.mainDocument);
o = ["Number of parts: " + parts.length];
for (var i = 0; i < parts.length; i++) {
    o.push("Part #" + (i + 1).toString() + " uri: " + parts[i].uri);
}
// Note that there are convenience functions that retrieve the most commonly used parts.
// var mainPart = doc.mainDocumentPart() also returns the main document part.
return { output: o };