Shared concepts

Production decisions.

Choices that apply across DOCX, XLSX, and PPTX.

Choose where layout and paint run.

Parsing always runs in a Worker. Keep the default mode: 'main' for ordinary previews. Choose mode: 'worker' when document layout and Canvas paint compete with your application's UI.

mainworker
Layout and paintMain threadWeb Worker
Best fitMost previews and custom renderer objectsLarge or complex files
Browser requirementCanvasWorker and OffscreenCanvas

Let one Viewer own one document, unless views need to share it.

The usual path is to construct a Viewer, call load(source), and destroy the Viewer when its host unmounts. The Viewer owns the loaded document.

Load the document model yourself only when several views must share one parse. Destroy every borrowed view before destroying the shared model.

FormatShared modelBorrowing factory
DOCXDocxDocumentfromDocument()
PPTXPptxPresentationfromPresentation()
XLSXXlsxWorkbookfromWorkbook()
import { DocxDocument, DocxScrollViewer } from '@silurus/ooxml/docx';

const document = await DocxDocument.load(source, { mode: 'worker' });
const first = DocxScrollViewer.fromDocument(firstContainer, document);
const second = DocxScrollViewer.fromDocument(secondContainer, document);

// Destroy every view before the shared document.
first.destroy();
second.destroy();
document.destroy();

Add only the rendering modules a product needs.

Equations, ChartEx, 3-D charts, and Region Maps use separate package entries and the same Viewer options across DOCX, XLSX, and PPTX. Classic 2-D charts remain included with each format.

import { XlsxViewer } from '@silurus/ooxml/xlsx';
import { math } from '@silurus/ooxml/math';
import { chartEx } from '@silurus/ooxml/chart-ex';
import { threeD } from '@silurus/ooxml/three-d';
import { regionMap } from '@silurus/ooxml/region-map';

const viewer = new XlsxViewer(container, {
  math,
  chartEx,
  threeD,
  regionMap,
});
CapabilityImportViewer option
Equation renderer @silurus/ooxml/math math
Microsoft ChartEx renderer @silurus/ooxml/chart-ex chartEx
3-D chart renderer @silurus/ooxml/three-d threeD
Offline Region Map renderer @silurus/ooxml/region-map regionMap