OpenXmlPackage.getPartsByContentType (contentType)
Return to the
Open XML SDK for JavaScript
Developer CenterGets an array of parts with the specified content type. openXml.contentTypes contains a list of the most common content types.
Syntax
var parts = OpenXmlPackage.getPartsByContentType(contentType);
Arguments
contentType: An string that contains the content type.
Return Value
Returns an array of OpenXmlPart objects. If there are no parts with the specified content type, this function returns a zero length array.
Usage
var parts = doc.getPartsByContentType(openXml.contentTypes.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.getPartsByContentType(openXml.contentTypes.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 };