# テーブル

> Facade API で構造化 PDF テーブルを挿入、サイズ変更、スタイル設定、編集します。

- Human documentation: [https://docs.univer.ai/ja-JP/guides/pdfs/features/core/tables](https://docs.univer.ai/ja-JP/guides/pdfs/features/core/tables)

- Agent Markdown: [https://docs.univer.ai/ja-JP/guides/pdfs/features/core/tables.md](https://docs.univer.ai/ja-JP/guides/pdfs/features/core/tables.md)

- Requested language: `ja-JP`

- Content language: `ja-JP`

- Documentation version: `1.2.0`

- Source: [pdfs/features/core/tables.ja-JP.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/pdfs/features/core/tables.ja-JP.mdx)

---

`FPdfTable` は、安定したセルラッパーとセルごとの編集可能なテキストストーリーを持つ構造化グリッドを保持します。

## テーブルを挿入、編集する

```ts
const table = page.insertTable({
  rowCount: 2,
  columnCount: 2,
  cellTexts: ['Owner', 'Status', 'Docs', 'Ready'],
  left: 36,
  top: 36,
  width: 360,
  height: 108,
})

table.resize(3, 2)
table.getCell(2, 0).setText('Legal')
table.getCell(2, 1).setText('Review')
```

行数と列数は正の安全な整数である必要があり、テーブルは 10,000 セルを超えられません。サイズ変更では重なるセルが位置に基づいて維持されます。

## テーブルテーマを適用する

```ts
const [preset] = univerAPI.getPdfTableThemePresets()

if (preset) {
  table.setTheme({
    styleId: preset.id,
    options: { firstRow: true },
  })
}
```

`getPdfTableThemePresets()` は切り離された `{ id, group }` 記述子を返します。プリセットの `id` を `styleId` として使い、記述子自体を `setTheme()` に渡さないでください。

## セルのスタイル

```ts
table.getCell(0, 0).setStyle({
  fill: { color: '#eef3ff' },
  fontColor: '#1d4ed8',
  horizontalAlignment: univerAPI.Enum.HorizontalAlign.CENTER,
  verticalAlign: univerAPI.Enum.PdfTableCellVerticalAlign.MIDDLE,
})
```

`FPdfTableCell.setStyle()` はコンテナフィールドに加え、セル全体の `fontColor` と `horizontalAlignment` を受け取ります。`PdfTableCellVerticalAlign` は `univerAPI.Enum` から使用します。

テーブルのメソッドは `getRowCount()`、`getColumnCount()`、`getCell()`、`resize()`、`getTheme()`、`setTheme()` です。セルのメソッドは `getText()`、`setText()`、`getStyle()`、`setStyle()` です。
