> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/blocks/table.md).

# 表格

使用表格保持信息有序，并让数据文档化更轻松

你可以添加表格，以便在 GitBook 页面中更好地组织信息。你可以在下面的示例表格中查看可实现的效果：

<table data-full-width="false"><thead><tr><th>公司</th><th>状态<select><option value="36bef47f343d4588bc43db3e5c701796" label="进行中" color="blue"></option></select></th><th>联系</th><th>月经常性收入</th><th data-hidden>联系</th><th data-hidden>月经常性收入</th><th data-hidden>状态<select><option value="3e7a52c673ec4a01992566d18271f7a5" label="进行中" color="blue"></option><option value="2362fd3eafc7476fb8646ac754f34b72" label="完成" color="blue"></option></select></th></tr></thead><tbody><tr><td><strong>Ace AI</strong> – 设计</td><td><span data-option="36bef47f343d4588bc43db3e5c701796">进行中</span></td><td><a href="mailto:noreply@gitbook.com">rena@ace.ai</a></td><td>$450</td><td><a href="mailto:noreply@gitbook.com">rena@ace.ai</a></td><td>$420</td><td><span data-option="3e7a52c673ec4a01992566d18271f7a5">进行中</span></td></tr><tr><td><strong>离散数据</strong> – API</td><td><span data-option="36bef47f343d4588bc43db3e5c701796">进行中</span></td><td><a href="mailto:noreply@gitbook.com">dave@dd.inc</a></td><td>$100</td><td><a href="mailto:noreply@gitbook.com">dave@dd.inc</a></td><td>$69</td><td></td></tr><tr><td><strong>示例公司</strong></td><td></td><td><a href="mailto:pete@example.com">pete@example.com</a></td><td>$50</td><td></td><td></td><td></td></tr></tbody></table>

### 表格块选项

当你打开表格块左侧的“选项”菜单时，你会有多个选项来更改外观并管理表格中的数据：

* **表格/卡片：** 选择将数据显示为表格块或卡片块。GitBook 会使用相同的数据填充这两种块，因此你可以根据所需的外观和设计在两者之间切换。
* **添加列：** 在表格右侧添加新列。你可以使用菜单选择列类型，也可以直接点击 **添加列** 以添加文本列。
* **插入行：** 在表格底部添加新行。
* **显示表头：** 隐藏或显示表格顶部的标题行。
* **冻结表头：** 滚动下方各行时，让表格顶行始终显示在页面上。这对较大的表格很有用，可以让列标题始终保持可见。
* **冻结首列：** 向右水平滚动浏览各列时，让表格最左侧的列始终可见。这对宽度超出页面的宽表格很有用，可以让行标签或标识符始终保持可见。
* **重置列宽：** 如果你更改了列宽，此操作会将所有列宽重置为相同大小。
* **可见列：** 选择要显示或隐藏的列。如果表格中有隐藏列，可以在此菜单中重新显示这些列。
* **删除：** 删除表格块及其所有内容。

### 合并单元格

通过拖动选中多个单元格，或按住 Shift 并按方向键来选择多个单元格。选中单元格后，使用出现的把手将它们合并。

合并仅适用于 **文本** 和 **数字** 单元格。对于不受支持的字段、混合字段类型、锚定单元格之外的评论以及卡片视图，GitBook 不允许合并。GitBook 也不允许重新排列已合并的单元格或包含合并单元格的行。

使用 Git Sync 时，合并会采用原生的 `colspan` 和 `rowspan` 。合并按位置确定：锚定单元格和跨行、跨列范围会随表格当前的行顺序和可见列顺序而定。

第一个版本不支持矩形合并，例如 `2x2` 选区。合并单元格时，请选择要保留的值。GitBook 会清除其他值。取消合并不会恢复已清除的值。

### 更改列类型

根据你要显示的数据，可以为表格列设置不同的数据类型。这些类型会为该列中的每个单元格添加格式、装饰或限制：

* **文本：** 标准文本列，支持常规格式设置。
* **数字：** 数字列，可包含或不包含小数位。
* **复选框：** 每行都有一个可勾选或取消勾选的复选框。
* **选择：** 您可以从选项列表中选择数据。打开 **列选项** 菜单并选择 **管理选项**。您可以设置为单选或多选。
* **用户：** 您可以添加组织成员的姓名和头像。此项可以设为单选或多选。
* **文件：** 在此部分中引用文件。填写此列中的单元格时，您可以上传新文件。
* **评分：** 星级评分。您可以打开 **列选项** 菜单并选择 **上限**.

使用 **列选项** 菜单更改列的类型。更改列类型时，系统会提示您确认更改，因为此操作可能会删除或破坏列中的数据。

### 调整列宽

将鼠标悬停在列边缘并拖动即可调整大小。光标上方会显示像素数，帮助你设置一致的列宽。

GitBook 将列宽存储为整体宽度的百分比，这使得可以根据表格整体宽度进行相对调整。

### 可滚动表格

宽度大于编辑器容器的表格可以水平滚动。

### 列选项

如需重新排列列，请单击并拖动 <picture><source srcset="broken://files/HXFvPsjDqbaBEhpH0WKJ" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-f73bf8251d7a6786ca6595b4593501e11512d107%2F25_02_04_actions_horizontal_1.svg?alt=media" alt="The table drag handle icon in GitBook"></picture> 要移动的列顶部的拖动手柄。

您可以单击悬停在表格右侧边缘时显示的 **添加列** 按钮来添加新列。

在 **列选项** 菜单中，您还可以开启或关闭自动调整大小、在右侧添加新列、隐藏列或删除列。

### 行选项

将鼠标悬停在行上，然后单击其左侧显示的 **行选项** <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-aabbca522107ef561981bdfe5af94605b31e0920%2F25_01_10_actions_icon_light.svg?alt=media" alt="The Row options menu icon in GitBook"></picture> 按钮以打开 **行选项** 菜单。您会看到多个选项：

* **打开行：** 在模态窗口中打开该行并显示其中的所有数据。在这里，您可以快速更改行类型、编辑数据，并查看隐藏列中的数据。
* **在上方/下方插入：** 在当前选中的行上方或下方添加新行。
* **添加列：** 在表格右侧添加新列。
* **删除行：** 从表格中永久删除该行的所有数据。

### 表格中的图片

当你点击表格单元格时，可以按 / 键插入图片。图片不能添加到表格的表头行。

### Markdown 表示

```markdown
# 表格

|   |   |   |
| - | - | - |
|   |   |   |
|   |   |   |
|   |   |   |
```

<details>

<summary>我可以在 GitBook 中创建嵌套表格吗？</summary>

在 GitBook 中无法嵌套表格。为了确保文档易于编写、渲染可靠，并且对所有用户都可访问，GitBook 会保持表格为扁平结构。

一旦表格嵌入另一个表格单元格中，就会变得难以编辑、调整大小、导航，或在不同设备间保持一致的格式。

嵌套表格也会给底层文档结构带来显著复杂性，常常破坏清晰的语义，并导致 Git Sync 等功能出现不可预测性。

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/blocks/table.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
