StaticopenOpens an Open XML document from any supported format.
The document to open.
A promise resolving to an OpenXmlPackage instance.
Auto-detects the input format: binary Blob, Base64 string, or Flat OPC XML string. For format-specific packages, use WmlPackage.open, SmlPackage.open, or PmlPackage.open instead.
// Open from binary Blob
const buffer = fs.readFileSync("document.docx");
const pkg = await OpenXmlPackage.open(new Blob([buffer]));
// Open from Base64 string
const base64 = fs.readFileSync("document.txt", "utf-8");
const pkg2 = await OpenXmlPackage.open(base64);
// Open from Flat OPC XML string
const flatOpc = fs.readFileSync("document.xml", "utf-8");
const pkg3 = await OpenXmlPackage.open(flatOpc);
Returns all content parts in the package, excluding the content-types part and relationship parts.
An array of all content OpenXmlPart instances in the package.
Adds a new part to the package.
The part URI (e.g., "/word/comments.xml").
The MIME content type. Use ContentType constants.
The part data type: "xml", "binary", or "base64".
The part content (an XDocument for XML parts, or a string/Blob for binary).
The newly created OpenXmlPart.
Removes a part from the package and cleans up any relationships that reference it.
The part to delete.
Looks up a part by its URI.
The full part URI (e.g., "/word/document.xml").
The matching OpenXmlPart, or undefined if not found.
Returns all package-level relationships (from /_rels/.rels).
An array of OpenXmlRelationship objects.
Returns package-level relationships filtered by relationship type.
The relationship type URI. Use RelationshipType constants.
An array of matching OpenXmlRelationship objects.
Returns parts that are targets of package-level relationships of the given type.
The relationship type URI. Use RelationshipType constants.
An array of matching OpenXmlPart instances.
Finds a package-level relationship by its ID.
The relationship ID (e.g., "rId1").
The matching OpenXmlRelationship, or undefined.
Finds a part by following a package-level relationship ID.
The relationship ID (e.g., "rId1").
The target OpenXmlPart, or undefined.
Returns package-level relationships whose target parts have the given content type.
The MIME content type. Use ContentType constants.
An array of matching OpenXmlRelationship objects.
Returns parts whose content type matches the given value.
The MIME content type. Use ContentType constants.
An array of matching OpenXmlPart instances.
Returns the first part targeted by a package-level relationship of the given type.
The relationship type URI. Use RelationshipType constants.
The first matching OpenXmlPart, or undefined.
Returns the core file properties part (title, author, dates, etc.).
The core properties OpenXmlPart, or undefined if not present.
Returns the extended file properties part (application name, company, etc.).
The extended properties OpenXmlPart, or undefined if not present.
Returns the custom file properties part.
The custom properties OpenXmlPart, or undefined if not present.
Returns all relationships defined for a specific part.
The part whose relationships to retrieve.
An array of OpenXmlRelationship objects.
Adds a package-level relationship.
The relationship ID (e.g., "rId10").
The relationship type URI. Use RelationshipType constants.
The target URI.
"Internal" (default) or "External".
The newly created OpenXmlRelationship.
Adds a relationship to a specific part.
The source part.
The relationship ID.
The relationship type URI. Use RelationshipType constants.
The target URI (relative to the source part).
"Internal" (default) or "External".
The newly created OpenXmlRelationship.
Deletes a relationship from a specific part.
The source part.
The relationship ID to delete.
true if the relationship was deleted.
Saves the package as a Flat OPC XML string.
A promise resolving to the Flat OPC XML string.
Saves the package as a binary Blob (ZIP).
A promise resolving to a Blob containing the document bytes.
Base class for all Open XML document packages.
Remarks
An Open XML package is a ZIP archive (or equivalent Flat OPC / Base64 representation) containing parts (XML documents, images, and other binary data) linked by relationships.
OpenXmlPackageprovides format-agnostic opening and saving, part management, and relationship navigation. For format-specific convenience methods, use the subclasses WmlPackage, SmlPackage, or PmlPackage.The static open() method auto-detects the input format: binary Blob, Base64 string, or Flat OPC XML string.
Example