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
| Property | Type | Description |
|---|---|---|
| id | string | Unique document unit ID. |
| rev? | number | Document revision, used by collaborative editing. |
| locale? | LocaleType | Locale of the document. |
| title? | string | Document title. |
| body? | IDocumentBody | Main rich-text body. Details |
| documentStyle | IDocumentStyle | Document-level page, layout, header/footer, and default text style settings. |
| settings? | IDocumentSettings | Runtime settings such as zoomRatio. |
| resources? | IResources | Plugin resources. |
| disabled? | boolean | Whether the document is disabled. |
| headers? | IHeaders | Header bodies keyed by header ID. |
| footers? | IFooters | Footer bodies keyed by footer ID. |
| lists? | ILists | List definitions used by paragraph bullets. |
| drawings? | IDrawings | Drawing objects such as images. |
| drawingsOrder? | string[] | Rendering order of drawings. |
| tableSource? | ITables | Table 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:
- Creating a Univer Docs document
- Saving a Univer Docs snapshot
- Importing or exporting
.docxfiles - 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?