Document Body Structure

IDocumentBody

IDocumentBody stores the main flow content of a Univer Docs document.

The text itself is stored in dataStream. Styles and structure are stored in parallel arrays, and each entry is linked to the text by index.

Properties

PropertyTypeDescription
dataStreamstringThe document body as plain text. Special characters mark paragraphs, section breaks, tables, and custom blocks.
textRuns?ITextRun[]Inline style ranges.
paragraphs?IParagraph[]Paragraph metadata and paragraph styles.
sectionBreaks?ISectionBreak[]Section break metadata.
customBlocks?ICustomBlock[]Plugin-defined block placeholders.
tables?ICustomTable[]Table markers in the document body. Table definitions are stored in IDocumentData.tableSource.
columnGroups?ICustomColumnGroup[]Column group markers.
blockRanges?IDocumentBlockRange[]Structured block ranges such as callout, quote, and code blocks.
customRanges?ICustomRange[]Special ranges such as hyperlinks, fields, bookmarks, comments, mentions, and plugin-defined ranges.
customDecorations?ICustomDecoration[]Decoration ranges such as comment highlights.
payloads?Record<string, string>Temporary copy/paste payloads. This field is not persisted.

dataStream

dataStream is the authoritative source of the body text. A paragraph usually ends with \r\n.

TypeScript
const body: IDocumentBody = {  dataStream: 'Title\r\nHello Univer\r\n',  paragraphs: [    { startIndex: 5, paragraphId: 'p-title' },    { startIndex: 19, paragraphId: 'p-body' },  ],}

Special characters

Some elements are stored as control characters in dataStream and expanded by the renderer:

CharacterMeaning
\r\nParagraph break
\nSection break
\fPage break
\vColumn break
\tTab
\0Document end
\bCustom block placeholder

Tables and custom ranges also use control characters internally. When working with tables, links, comments, or block-level features, use Facade APIs or commands instead of writing control characters by hand.

Relationship with IDocumentData

IDocumentBody covers only the main document flow. All other resources are stored on IDocumentData:

  • tableSource stores table definitions.
  • drawings stores image and drawing objects.
  • headers and footers each contain their own IDocumentBody.
  • lists stores list definitions referenced by paragraph bullets.
  • resources stores plugin-defined data.

How is this guide?

© 2026 DreamNum Co., Ltd.