OpenXmlPackage.getPartByRelationshipType (relationshipType)

Return to the
Open XML SDK for JavaScript
Developer Center
Gets the part with the specified relationship type. If there is more than one part with the specified relationship type, this function returns the first one. openXml.relationshipTypes contains a list of the most common relationship types.

Syntax

    var part = OpenXmlPackage.getPartByRelationshipType(relationshipType);

Arguments

    relationshipType: An string that contains the relationship type.

Return Value

    Returns an OpenXmlPart object. If there is no part related with the specified relationship type, this function returns null.

Usage

    var mainPart = doc.getPartByRelationshipType(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 mainPart = doc.getPartByRelationshipType(openXml.relationshipTypes.mainDocument);
// Note that there are convenience functions that retrieve the most commonly used parts.
// var mainPart = doc.mainDocumentPart() also returns the main document part.
if (mainPart !== null) {
    o = "Found the part, uri = " + mainPart.uri;
}
return { output: o };