Document Data Structure

IDocumentData

IDocumentData is the snapshot format used by Univer Docs.

It describes a complete document unit, including the text body, document-level style, 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.
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 for:

  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 a persisted data structure. Do not mutate it directly after a document is running. Use Facade APIs or commands to modify document content.

How is this guide?

© 2026 DreamNum Co., Ltd.