Getting Started
Additional Formats
Parse legacy Office and ODF files; read, write, and patch RTF and ODF; and convert CSV/TSV
The umbrella package provides one detection and parsing entry while preserving the existing option families. There is no separate legacy edit model: parsed documents are projected into DocumentOptions, WorkbookOptions, or PresentationOptions.
#Format Matrix
| Formats | Parse | Generate | Patch | Result model |
|---|---|---|---|---|
.doc, .xls, .ppt | ✅ | ❌ | ❌ | Existing document/workbook/presentation options |
.rtf | ✅ | ✅ | ✅ | DocumentOptions |
.odt, .ods, .odp | ✅ | ✅ | ✅ | Canonical format-family options |
.csv, .tsv | ✅ | ✅ | ❌ | WorkbookOptions conversion via office-open/convert only |
Legacy binary parsing is intentionally read-only. The shared option models remain the editing and persistence contract used by OOXML, the editor, and cross-format conversion.
#RTF Generation
import { generateOffice } from "office-open";
const data = await generateOffice("rtf", {
sections: [{ children: [{ paragraph: "Written as RTF" }] }],
});
RTF generation writes the parser's strict DocumentOptions projection. Unsupported OOXML-only fields raise RtfGenerateError with a canonical path and reason; the writer never silently drops supported canonical data.
RTF patching parses the source, applies ordered canonical commands, and regenerates the file. It is a canonical edit rather than a byte-preserving rewrite; the same strict writer rules apply to the patched result.
ODF patching uses the same command model. Package-level overlays—source-only members, manifests, style resources, and embedded objects—remain in the canonical options and are written back unless a patch changes them.
OCF readers validate ZIP CRCs and sizes and require manifest declarations to match actual package members, including valid unique paths.
ODF document packages depend downward through internal odf code; peer ODF document packages do not import one another, and only the umbrella package aggregates all public codecs.
ODF document packages own their canonical typed surfaces. Internal odf modules own generic-node coverage for elements outside those surfaces; low-level chart and database codecs are implementation details, not aggregate API.
#Unified Parsing
import { readFile } from "node:fs/promises";
import { parseOffice } from "office-open";
const data = new Uint8Array(await readFile("input.doc"));
const parsed = await parseOffice(data);
The returned object contains the detected format and one of the three option families. String input is supported for RTF.
#ODF Generation
import { generateOffice } from "office-open";
const data = await generateOffice("odt", {
sections: [{ children: [{ paragraph: "Written as ODT" }] }],
});
ODF packages store an uncompressed leading mimetype and include the ODF 1.3 manifest required by conforming consumers.
For elements outside the canonical specialized surfaces, use the canonical family packages that expose the supported ODF projection.
reproducible applies to OOXML OPC output only. ODT/ODS/ODP writers reject the option instead of silently ignoring it.
#CSV and TSV
import { csvToWorkbook, tsvToWorkbook } from "office-open/convert";
const workbook = csvToWorkbook("name,score\nAda,99");
Delimited-text conversion follows RFC 4180, preserves quoted line breaks, and keeps parsed cell values as strings without type guessing.