Optional add-on · experimental

Legacy Office files.

Read a supported subset of .doc, .xls and .ppt with the same viewers.

An experimental opt-in.

OOXML Viewer remains a viewer for DOCX, XLSX and PPTX. The separate @silurus/ooxml-legacy-office package adds experimental reading of legacy binary Office files. Each reader projects a supported binary subset directly into the existing document, workbook or presentation model; the same layout and Canvas renderers display it. No intermediate OOXML package is generated.

npm i @silurus/ooxml @silurus/ooxml-legacy-office

The package versions must match exactly. The add-on pins its viewer peer dependency to that exact version. Upgrade both together; stale runtime or protocol combinations fail before input loading with companion-runtime-mismatch.

No migration is required for applications that do not opt in. Ordinary viewer imports do not import, fetch or initialize a legacy reader.

Enable each format explicitly.

Import a reader and pass it as its own option, like the other opt-in modules: { legacyDoc }, { legacyXls } or { legacyPpt }. The DOC reader enables DOC only; XLS and PPT each need their own reader. Modern OOXML input continues through the ordinary parser. Admission checks inspect the bytes, not the filename.

DOC → DOCX Viewer

import { DocxViewer } from '@silurus/ooxml/docx';
import { legacyDoc } from '@silurus/ooxml-legacy-office/doc';

const canvas = document.querySelector('#document') as HTMLCanvasElement;
const viewer = new DocxViewer(canvas, { legacyDoc });
await viewer.load(await file.arrayBuffer());
// When the preview is removed:
viewer.destroy();

XLS → XLSX Viewer

import { XlsxViewer } from '@silurus/ooxml/xlsx';
import { legacyXls } from '@silurus/ooxml-legacy-office/xls';

const container = document.querySelector('#workbook') as HTMLElement;
const viewer = new XlsxViewer(container, { legacyXls });
await viewer.load(await file.arrayBuffer());
// When the preview is removed:
viewer.destroy();

PPT → PPTX Viewer

import { PptxViewer } from '@silurus/ooxml/pptx';
import { legacyPpt } from '@silurus/ooxml-legacy-office/ppt';

const canvas = document.querySelector('#presentation') as HTMLCanvasElement;
const viewer = new PptxViewer(canvas, { legacyPpt });
await viewer.load(await file.arrayBuffer());
// When the preview is removed:
viewer.destroy();

The same option works with DocxDocument.load(), XlsxWorkbook.load(), PptxPresentation.load() and the scroll viewers, in both main and worker rendering modes.

Use the same source in a bounded session.

import { readFile } from 'node:fs/promises';
import { openPptxPresentation } from '@silurus/ooxml/node';
import { legacyPpt } from '@silurus/ooxml-legacy-office/ppt';

const session = await openPptxPresentation(await readFile('presentation.ppt'), { legacyPpt });
try {
  for await (const slide of session.slides()) {
    // Consume each ordinary slide model in your application.
  }
} finally {
  await session.close();
}

openDocxDocument, openXlsxWorkbook and the materialization APIs also accept the same option. Keep the normal canvas factory options when rendering in Node, and close sessions in finally. Node sessions retain their signal option.

Check the boundary before enabling it.

The readers are experimental. They reject input they cannot represent instead of showing a partial document. They do not execute macros, fields, formulas, actions or embedded objects. Stored results and supported layout fields can be displayed; this is not an Office fidelity guarantee.

ReaderSupported classesBoundaries
DOCWord 97–2003 binary content projected to the DOCX model, including supported text, tables, drawings, fields and notes.Unimplemented formatting, fields and numbering can reject the document. Notes require supported numbering and placement; custom reference marks and restarts reject.
XLSA BIFF8 subset: cell values and cached formula results, formatting, merged cells, outlines, frozen panes, tables, supported conditional formatting, charts and drawings.Unsupported variants reject, including active AutoFilter criteria. Stored formulas are not recalculated. Print setup, headers and footers do not drive a paginated spreadsheet view.
PPTSupported binary slides, text, shapes, pictures and fills projected to the PPTX model. Supported embedded objects display their stored picture only.No audio/video or embedded fonts. Unresolvable text properties, linked objects, ActiveX and unsupported picture or fill variants reject.

All three readers lack Markdown export and ZIP accounting. toMarkdown() rejects; resource metrics have no ZIP usage snapshot. Password-protected legacy binaries, pre-CFB formats and unsupported binary structures are outside the supported subset.

Read the full support list and compatibility boundaries on GitHub →

Keep a conversion fallback.

Without a matching source, legacy binary input rejects with OoxmlError, code === 'legacy-binary-format'. Enable the corresponding add-on source or ask for conversion to DOCX, XLSX or PPTX. An unclaimed or ambiguous container still takes the ordinary OOXML path, including its encryption errors.

Once a source claims the file, reader failure rejects the load with no fallback to another source or parser. Unsupported claimed content uses OoxmlError with code === 'unsupported-content' and content-free details: { format: 'doc' | 'xls' | 'ppt', reason: 'source-subset' }. Offer conversion for this code, including failures during lazy reads. Do not branch on message text. Encryption, resource limits, crashes and companion mismatches remain distinct. The optional maxInputBytes guard accepts any positive safe integer and throws a RangeError when claimed input exceeds it. There is no default input-size ceiling. To retain the former 256 MiB limit, explicitly set maxInputBytes: 256 * 1024 * 1024.

Error delivery and application messages →

Pay for the reader only when used.

Each format has its own source entry, self-contained ES source module and dedicated WASM. Importing a reader fetches nothing. Its module and WASM are fetched only when the reader claims a file, in the parser Worker or Node. Import the entry dynamically when selecting a legacy file to defer even the small calling entry.

Serve the emitted source modules and legacy_doc_direct_bg.wasm, legacy_xls_direct_bg.wasm or legacy_ppt_direct_bg.wasm with the package assets. A custom asset pipeline can create the reader with createLegacyDoc, createLegacyXls or createLegacyPpt and absolute moduleUrl and wasmUrl options. Allow the source module URL in CSP rules for scripts and Worker imports.

import { createLegacyPpt } from '@silurus/ooxml-legacy-office/ppt';

const legacyPpt = createLegacyPpt({
  moduleUrl: new URL('/assets/legacy-ppt-source-module.mjs', location.href).href,
  wasmUrl: new URL('/assets/legacy_ppt_direct_bg.wasm', location.href).href,
});
const viewer = new PptxViewer(canvas, { legacyPpt });

Bundle and runtime asset costs → · Try a file locally →