ドキュメントデータ構造
IDocumentData
IDocumentData は Univer Docs が使用するスナップショット形式です。
本文、ドキュメント全体のスタイル、ヘッダーとフッター、画像、リスト、テーブル、プラグインリソースを含む 1 つのドキュメント単位を表します。
プロパティ
| プロパティ | 型 | 説明 |
|---|---|---|
| id | string | ドキュメント単位の一意な ID。 |
| rev? | number | 共同編集で使用されるドキュメントのリビジョン。 |
| locale? | LocaleType | ドキュメントのロケール。 |
| title? | string | ドキュメントタイトル。 |
| body? | IDocumentBody | 本文のリッチテキストデータ。詳細 |
| documentStyle | IDocumentStyle | ページ、レイアウト、ヘッダー/フッター、既定のテキストスタイル設定。 |
| settings? | IDocumentSettings | zoomRatio などの実行時設定。 |
| resources? | IResources | プラグインリソース。 |
| disabled? | boolean | ドキュメントが無効かどうか。 |
| headers? | IHeaders | ヘッダー ID を key にしたヘッダー本文。 |
| footers? | IFooters | フッター ID を key にしたフッター本文。 |
| lists? | ILists | 段落の箇条書きで使用されるリスト定義。 |
| drawings? | IDrawings | 画像などの描画オブジェクト。 |
| drawingsOrder? | string[] | 描画オブジェクトのレンダリング順序。 |
| tableSource? | ITables | 本文から参照されるテーブル定義。 |
例
TypeScript
const documentData: IDocumentData = { id: 'doc-1', title: 'Demo Document', locale: LocaleType.JA_JP, 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, },}利用シーン
IDocumentData は主に次の用途で使用します。
- Univer Docs ドキュメントを作成する
- Univer Docs のスナップショットを保存する
.docxファイルをインポートまたはエクスポートするICellData.pを通じて Sheets セルにリッチテキストを保存する
スナップショットは永続化用のデータ構造です。ドキュメントの実行中に直接変更せず、Facade API またはコマンドを使用して内容を変更してください。
このガイドはいかがですか?