OpenXmlSdkTs is a TypeScript library for reading, writing, and manipulating Office Open XML documents -- the file formats behind .docx, .xlsx, and .pptx files. It brings the programming model of the well-known .NET Open XML SDK to the TypeScript/JavaScript ecosystem.
XName properties on dedicated namespace classes (W, S, P, A, R, NoNamespace, and more). This enables O(1) identity comparisons instead of string matching.XDocument, XElement, XAttribute, XName, and XNamespace.mainDocumentPart(), workbookPart(), and presentationPart().jszip and ltxmlts.OpenXmlPackage (base)
├── WmlPackage (.docx)
├── SmlPackage (.xlsx)
└── PmlPackage (.pptx)
OpenXmlPart (base)
├── WmlPart (Word parts)
├── SmlPart (Excel parts)
└── PmlPart (PowerPoint parts)
OpenXmlRelationship
Packages contain parts, and parts contain XML content. You open a package, navigate to the part you need, retrieve its XML document, query or modify it, and save the package back out.
The library provides over 48 namespace classes that give you pre-atomized XName constants for every element and attribute in the Open XML specification:
| Class | Description |
|---|---|
W |
WordprocessingML (word processing elements) |
S |
SpreadsheetML (spreadsheet elements) |
P |
PresentationML (presentation elements) |
A |
DrawingML (drawing/graphics elements) |
R |
Relationships |
NoNamespace |
Unqualified attributes (val, id, type, name, etc.) |
M, MC, WP, WPS, WPC, W14, W15, ... |
Additional specialized namespaces |
Each class exposes a static namespace property (the XNamespace) and static XName properties for every element and attribute name in that namespace.
The library includes two lookup objects that enumerate every content type and relationship type defined in the Open XML specification:
ContentType.WmlDocument resolves to application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml).RelationshipType.OfficeDocument resolves to the appropriate URI).These are used when querying for parts by type or when adding new parts and relationships to a package.
OpenXmlSdkTs is inspired by the Open XML SDK for .NET. Developers familiar with the .NET SDK will recognize the same package/part/relationship model and the same LINQ to XML approach to working with document content.