Import and export

The APIs on this page require a conversion backend. Configure file exchange integration first so that uploads, conversion, task queries, and downloads work, and then configure the browser plugins. Snapshot APIs require the same backend but do not require a collaborative document.

For export failures, see license error codes and task failure handling.

For imported Office attachments, see OLE previews, online conversion, and export source selection.

Supported formats

The table lists the formats supported by the browser APIs on this page. Office file conversion additionally requires a backend that supports the same document type and format.

ImportExport
.xls, .xlsx, .csv, .tsv.xlsx, .csv, .tsv

CSV and TSV export a single worksheet, without workbook formatting or the other worksheets. Pass ExchangeFormat.CSV or ExchangeFormat.TSV together with the sheetId to the export API; XLSX is the default. The browser API does not accept .xlsm, even when the conversion backend supports it.

Facade API

Importing

Plugin mode note

Only plugin mode requires importing the Facade package manually. Preset mode already includes the matching package.

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

Importing .xlsx

Import .xlsx file and get unitId

Caution

This method requires collaboration: it creates a document on the server and returns a unitId. If collaboration is not enabled, use snapshot import instead.

When collaborative editing is enabled, every document has a unique unitId. Pass a file to univerAPI.importSheetToUnitIdAsync, and the method returns that unitId, which is used to open the document. file can be a File object or a remote file URL.

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

Import .xlsx file and get IWorkbookData

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

univerAPI.importSheetToSnapshotAsync imports a .xlsx file and returns the document data as IWorkbookData.

TypeScript
// Accept a File objectconst snapshot = await univerAPI.importSheetToSnapshotAsync(file)// Or accept a remote file URL// const snapshot = await univerAPI.importSheetToSnapshotAsync('https://example.com/filename.xlsx');// Create a new workbook via snapshotif (snapshot) univerAPI.createWorkbook(snapshot)

Exporting .xlsx

Export .xlsx file using unitId

Caution

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

When collaborative editing is enabled, every document has a unique unitId. Pass that unitId to univerAPI.exportSheetByUnitIdAsync, and the method returns a File object.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const unitId = fWorkbook.getId()const file = await univerAPI.exportSheetByUnitIdAsync(unitId)// Download the file through the Facade APIif (file) univerAPI.downloadFile(file, 'univer', 'xlsx')

Export .xlsx file using IWorkbookData

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

Pass the IWorkbookData to univerAPI.exportSheetBySnapshotAsync, and the method returns a File object.

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook()const snapshot = fWorkbook.save()const file = await univerAPI.exportSheetBySnapshotAsync(snapshot)// Download the file through the Facade APIif (file) univerAPI.downloadFile(file, 'univer', 'xlsx')

Removal of built-in import/export menus and UI interactions

Note

As of version 1.2.0, Univer no longer includes built-in import/export menus and UI interactions. The underlying services and Facade APIs remain available.

If the application still needs those menus and interactions, the migration example for built-in import/export menus and UI interactions shows how to restore them with a custom plugin. The full source code is available for online reading or download.

How is this guide?

© 2026 DreamNum Co., Ltd.