Cross-document embedding

Embed other Univer document types in spreadsheets, documents, slides, boards, and bases while keeping native editing capabilities.

Embed allows one Univer document to be edited inside another. A spreadsheet can be placed in a document, slides on a board, or a base in a workbook tab. The host document contains the embed, and the child document is the content it references. Each document keeps its own data model.

Supported locations

HostLocationSupported children
SheetsFloating object in a worksheet, workbook tabDocs, Slides, Boards, Bases
DocsBody content blockSheets, Slides, Boards, Bases
SlidesFloating object on a page, page listSheets, Docs, Boards, Bases
BoardsFloating object on the canvasSheets, Docs, Slides, Bases
BasesTable listSheets, Docs, Slides, Boards

Floating objects and body blocks display the child inside the host, and editing uses the capabilities of the child product. Tabs and list entries turn the child into a page that can be switched to; when that page is activated, the menu area is transferred to the child.

Built-in capabilities do not support PDF, embedding the same product type, or embedding another document inside an embedded child.

Register the plugins

Both products and their UI must first run in the same Univer instance. Embed does not replace their core plugins: embedding Docs in Sheets requires both Sheets and Docs. Keep the dependency versions aligned and configure UniverLicensePlugin as described in License configuration.

Shell
pnpm add @univerjs-pro/embed @univerjs-pro/embed-ui

Add these imports to the existing application and register the plugins before creating documents. univer is the existing Univer instance.

TypeScript
import { UniverEmbedPlugin } from '@univerjs-pro/embed'import { UniverEmbedUIPlugin } from '@univerjs-pro/embed-ui'import '@univerjs-pro/embed/facade'import '@univerjs-pro/embed-ui/lib/index.css'univer.registerPlugin(UniverEmbedPlugin)univer.registerPlugin(UniverEmbedUIPlugin)

Merge the default export of @univerjs-pro/embed-ui/locale/en-US into the existing locales configuration. Other languages use their own locale pack; see Internationalization.

@univerjs-pro/embed provides the embed relationship, reference resolution, and the Facade API. @univerjs-pro/embed-ui provides the containers, focus switching, and menus. @univerjs-pro/embed-unit-ui provides a standalone viewer for a referenced document and is not required for basic embedding.

Referenced-unit previews

Presets such as preset-sheets-advanced do not include the referenced-unit preview. Formula reference selection and the ReferencedDataSelector used by referenced data require UniverEmbedUIPlugin from @univerjs-pro/embed-ui, registered with its stylesheet and locale. When the application is assembled from a preset, register the plugin explicitly:

TypeScript
import { UniverEmbedUIPlugin } from '@univerjs-pro/embed-ui'import '@univerjs-pro/embed-ui/lib/index.css'univer.registerPlugin(UniverEmbedUIPlugin)

Merge @univerjs-pro/embed-ui/locale/en-US into the existing locales configuration as described above. The plugin registers both the formula reference picker and the referenced-data selector. Without it, a referenced unit cannot be previewed or selected from formula references.

Embed a document in a spreadsheet

The following function takes a workbook and a document that are already loaded in the same Univer instance and inserts a floating document in the active worksheet. Use the actual ID of the child in ref; type=doc must match unitType.

TypeScript
import type { FUniver } from '@univerjs/core/facade'import type { FDocument } from '@univerjs/docs/facade'import type { FWorkbook } from '@univerjs/sheets/facade'import '@univerjs-pro/embed/facade'import '@univerjs/docs/facade'import '@univerjs/sheets/facade'async function embedDocument(  univerAPI: FUniver,  workbook: FWorkbook,  document: FDocument,) {  const embed = univerAPI.createEmbed<FDocument>({    host: {      unitId: workbook.getId(),      surface: univerAPI.Enum.FEmbedHostSurface.SheetFloating,      context: { subUnitId: workbook.getActiveSheet().getSheetId() },    },    content: {      unitType: univerAPI.Enum.UniverInstanceType.UNIVER_DOC,      ref: `#unit=${encodeURIComponent(document.getId())}&type=doc`,    },  })  await embed.loadAsync()  return embed}

createEmbed() creates the relationship and sets its position in the host. loadAsync() loads the child and returns its Facade. Callers should await this function and handle loading failures. A local reference requires the target document to exist in the current instance; an ID alone does not create or download the document.

Choose a location

Select host.surface from univerAPI.Enum.FEmbedHostSurface. host.context describes where the content is placed in the host.

LocationEnum memberPosition parameters
Worksheet floating objectSheetFloatingsubUnitId selects the worksheet; placement selects the anchor mode, which defaults to Position
Workbook tabSheetTabsheetIndex, sheetName
Document body blockDocBlockstartIndex: UTF-16 offset in the dataStream of the body; omit it to append to the editable body
Slide floating objectSlideFloatingsubUnitId selects the page; left, top, width, height set bounds
Slide page listSlidePagepageIndex, pageName
Board floating objectBoardFloatingsubUnitId selects the page; left, top, width, height set bounds
Base table listBaseTabletableIndex, tableName

Insertion indices for lists are zero-based, and omitting an index appends to the end. Floating bounds use document model coordinates rather than browser viewport coordinates. Do not write scroll or zoom offsets directly into these values.

Choose the child's default view

displayTarget sets what the child shows first, regardless of where the child sits in the host. Pass it when the embed is created, or change it later with embed.setDisplayTarget().

ChildDefault view parameters
Sheets{ subUnitId: 'sheet-id' }
Slides{ pageId: 'page-id' }
Bases{ tableId: 'table-id', viewId: 'view-id' }; also supports dashboardId

Use stable IDs rather than display names. If the target no longer exists, the child falls back to its first available view. Navigation inside the child does not overwrite this default. Docs and Boards do not accept displayTarget.

Save and remove embeds

A host snapshot must retain the Embed plugin data in resources and the embed positions in the body, drawings, or lists of the host. The relationship stores a reference to the child and a default view; it does not automatically merge the current content of the child into the host snapshot. Applications that use local storage must save children separately and ensure that their references can be resolved after restoration.

univerAPI.listEmbeds({ hostUnitId }) lists the embeds of a host, and univerAPI.getEmbed({ hostUnitId, embedId }) retrieves a single embed. embed.remove() removes the embed from the host; it does not delete the persisted data of the child.

Load collaborative documents

For server documents, complete Browser collaboration integration first, then register the collaboration bridge:

Shell
pnpm add @univerjs-pro/collaboration-embed
TypeScript
import { UniverCollaborationEmbedPlugin } from '@univerjs-pro/collaboration-embed'univer.registerPlugin(UniverCollaborationEmbedPlugin)

This plugin depends on UniverCollaborationPlugin, UniverCollaborationClientPlugin, and UniverEmbedPlugin. It loads the child through the collaboration snapshot service and then joins the collaboration session of that child. Pass the real server document ID in #unit=...&type=...; access remains governed by the existing identity and authorization setup.

To use custom storage instead of the collaboration service, configure resourceRefUnitProviderRegistrations on UniverEmbedPlugin so that references resolve to document instances.

Additional options and methods are documented in the FEmbed API, FUniver API, and Embed plugin API.

How is this guide?

© 2026 DreamNum Co., Ltd.