# ドキュメントデータ構造

- Human documentation: [https://docs.univer.ai/ja-JP/guides/docs/model/document-data](https://docs.univer.ai/ja-JP/guides/docs/model/document-data)

- Agent Markdown: [https://docs.univer.ai/ja-JP/guides/docs/model/document-data.md](https://docs.univer.ai/ja-JP/guides/docs/model/document-data.md)

- Requested language: `ja-JP`

- Content language: `ja-JP`

- Documentation version: `1.1.0`

- Source: [docs/model/document-data.ja-JP.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/docs/model/document-data.ja-JP.mdx)

---

## IDocumentData

[`IDocumentData`](https://docs.univer.ai/ja-JP/guides/docs/model/document-data.md) は Univer Docs が使用するスナップショット形式です。

本文、ドキュメント全体のスタイル、ヘッダーとフッター、画像、リスト、テーブル、プラグインリソースを含む 1 つのドキュメント単位を表します。

### プロパティ

| プロパティ          | 型                   | 説明                                                   |
| -------------- | ------------------- | ---------------------------------------------------- |
| id             | `string`            | ドキュメント単位の一意な ID。                                     |
| rev?           | `number`            | 共同編集で使用されるドキュメントのリビジョン。                              |
| locale?        | `LocaleType`        | ドキュメントのロケール。                                         |
| title?         | `string`            | ドキュメントタイトル。                                          |
| body?          | `IDocumentBody`     | 本文のリッチテキストデータ。[詳細](https://docs.univer.ai/ja-JP/guides/docs/model/document-body.md) |
| 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` は主に次の用途で使用します。

1. [Univer Docs ドキュメントを作成する](https://docs.univer.ai/ja-JP/guides/docs/features/core/docs-api.md#create-document)
2. [Univer Docs のスナップショットを保存する](https://docs.univer.ai/ja-JP/guides/docs/features/core/docs-api.md#get-document-data)
3. [`.docx` ファイルをインポートまたはエクスポートする](https://docs.univer.ai/ja-JP/guides/docs/features/import-export.md)
4. `ICellData.p` を通じて Sheets セルにリッチテキストを保存する

> [!WARNING]
> スナップショットは永続化用のデータ構造です。ドキュメントの実行中に直接変更せず、Facade API またはコマンドを使用して内容を変更してください。
