Import and export

The APIs below need a conversion backend. Follow file exchange integration to connect uploads, conversion, task queries, and downloads, then configure the browser plugins. Snapshot APIs also need that backend, but do not require a collaborative document. The collaboration Exchange example demonstrates Sheets; check that your target release supports the file types you need.

Supported formats

The table describes the browser APIs on this page. Office file conversion requires a backend that supports the same document type and format.

ImportExport
.doc, .docx.docx

Both .doc and .docx use the import APIs below. Export produces .docx; exporting the legacy .doc format is not supported.

Facade API

Importing

Plugin mode note

Only plugin mode requires manually importing the Facade package. Preset mode already includes the corresponding Facade package, so no extra import is needed.

TypeScript
import '@univerjs-pro/exchange-client/facade'import '@univerjs-pro/docs-exchange-client/facade'

Importing .docx

Import .docx file and get unitId

Caution

This method requires collaboration: it creates a server document and returns a unitId. Use snapshot import if collaboration is not enabled.

When collaborative editing is enabled, each document has a unique unitId. Using univerAPI.importDocToUnitIdAsync with the file parameter will return the unitId, which can be used to access the document. The file parameter can be a File object or a remote file URL.

TypeScript
import '@univerjs-pro/collaboration-client/facade'const unitId = await univerAPI.importDocToUnitIdAsync(file)if (unitId) {  await univerAPI.getCollaboration().loadDocAsync(unitId)}

Import .docx file and get IDocumentData

Snapshot import does not require collaboration. Use unitId import for collaborative documents.

Using univerAPI.importDocToSnapshotAsync to import a .docx file will return the document data in the IDocumentData format.

TypeScript
// Accept a File objectconst snapshot = await univerAPI.importDocToSnapshotAsync(file)// Or accept a remote file URL// const snapshot = await univerAPI.importDocToSnapshotAsync('https://example.com/filename.docx');// Create a new document via snapshotif (snapshot) univerAPI.createDocument(snapshot)

Exporting .docx

Export .docx file using unitId

Caution

unitId export requires collaboration. If collaboration is not enabled, use snapshot export.

When collaborative editing is enabled, each document has a unique unitId. Using univerAPI.exportDocByUnitIdAsync with the unitId parameter will return a File object.

TypeScript
const fDocument = univerAPI.getActiveDocument()const unitId = fDocument.getId()const file = await univerAPI.exportDocByUnitIdAsync(unitId)// Download the file through the Facade APIif (file) univerAPI.downloadFile(file, 'univer', 'docx')

Export .docx file using IDocumentData

Snapshot export does not require collaboration and is suitable for local workflows.

Using univerAPI.exportDocBySnapshotAsync with IDocumentData will return a File object.

TypeScript
const fDocument = univerAPI.getActiveDocument()const snapshot = fDocument.save()const file = await univerAPI.exportDocBySnapshotAsync(snapshot)// Download the file through the Facade APIif (file) univerAPI.downloadFile(file, 'univer', 'docx')

How is this guide?

© 2026 DreamNum Co., Ltd.