Document Data Structure

IDocumentData

IDocumentData is the snapshot format for Univer Docs.

A snapshot describes one whole document unit: text body, document-level styles, headers and footers, drawings, lists, tables, and plugin resources.

Properties

PropertyTypeDescription
idstringUnique document unit ID.
rev?numberDocument revision, used by collaborative editing.
locale?LocaleTypeLocale of the document.
title?stringDocument title.
company?stringOrganization associated with the document, used by built-in property fields.
customProperties?Record<string, IDocumentCustomProperty>Editable document metadata referenced by property fields. Each value is a string, date, integer, number, or boolean.
body?IDocumentBodyMain rich-text body. Details
documentStyleIDocumentStyleDocument-level page, layout, header/footer, and default text style settings.
settings?IDocumentSettingsRuntime settings such as zoomRatio.
resources?IResourcesPlugin resources.
disabled?booleanWhether the document is disabled.
headers?IHeadersHeader bodies keyed by header ID.
footers?IFootersFooter bodies keyed by footer ID.
lists?IListsList definitions used by paragraph bullets.
drawings?IDrawingsDrawing objects such as images.
drawingsOrder?string[]Rendering order of drawings.
tableSource?ITablesTable definitions referenced by the document body.

Example

TypeScript
const documentData: IDocumentData = {  id: 'doc-1',  title: 'Demo Document',  locale: LocaleType.EN_US,  body: {    dataStream: 'Hello Univer\r\n',    textRuns: [      {        st: 0,        ed: 12,        ts: { fs: 14 },      },    ],    paragraphs: [      {        startIndex: 12,        paragraphId: 'paragraph-1',      },    ],  },  documentStyle: {    pageSize: { width: 595, height: 842 },    marginTop: 72,    marginBottom: 72,    marginLeft: 72,    marginRight: 72,  },}

Usage

IDocumentData is mainly used in four places:

  1. Creating a Univer Docs document
  2. Saving a Univer Docs snapshot
  3. Importing or exporting .docx files
  4. Storing rich text inside Sheets cells through ICellData.p

A snapshot is persisted data. Do not mutate it directly while a document is running; use Facade APIs or commands to change document content.

How is this guide?

© 2026 DreamNum Co., Ltd.