> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/chinese/guan-li-yu-she-zhi/setup/document-training/training-line-fields-table-training/defining-tables-and-columns.md).

# 定义表格和列

本指南介绍如何在 DocBits 中手动定义表格和列，以提取行项目。当自动检测无法完整识别表格结构，或者需要添加自定义字段时，这项功能尤其有用。

### 1. 打开表格提取视图

在 DocBits 中打开文档，然后点击 **“Table Training”** 按钮，进入表格提取视图。

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-7b9b3aa2b9ce093be324d9a9c21dfcb1ff316c5f%2Fdefine_tables_and_columns_1.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### 2. 激活训练模式

要手动定义或修改表格和列，请点击 **“TRAINING MODE”**。

<div align="center"><figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-95e6358348a1ef553692a41cf761cae10145a872%2Fdefine_tables_and_columns_2.png?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

### 3. 定义表格区域

进入训练模式后，您可以定义文档中的表格位置。您有两种选择：

#### 选项 1：使用自动检测

点击 **“Auto-Detect Tables”** 按钮，让 DocBits 尝试自动识别表格区域。

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-41129ebb6eae74f2b32a19f02564acf860801a3d%2Fdefine_tables_and_columns_3.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

如果检测成功，系统会自动显示表格轮廓。随后，您可以继续定义列。

#### 选项 2：手动定义表格

如果自动检测失败或结果不准确，您可以手动定义表格：

1. 点击 **“Edit”** 按钮，启用表格选择模式。
2. 在左侧的文档视图中，围绕表格区域绘制一个矩形。

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-5aa31ae86aeeead17f9eae6c8f04bebeb235c647%2Fdefine_tables_and_columns_4.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### 4. 添加和定义列

定义表格后，您可以通过以下按钮手动定义列：\\

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-4240ac3b80e3e5265c22d72a6230e758376038af%2Fdefine_tables_and_columns_5.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

在文档上通过拖放来定义列并调整列顺序。对其他页面上的表格重复此操作。如果每页上的表格相同，您也可以使用以下按钮，将同一组列应用到文档中定义的所有表格。此功能会将您定义的列复制到其他所有页面：

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-62c6b4968a7fc2926fe258366be780e7bf91e932%2Fdefine_tables_and_columns_6.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

对于内容密集或结构复杂的文档，可以使用**缩放**功能更准确地定义列。例如，当信息排列得很紧密，导致列难以定义时：

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-3aecccfea7ed5ddd1a5906945d124d35ad727ffe%2Fdefine_tables_and_columns_7.png?alt=media" alt="" width="277"><figcaption></figcaption></figure>

如果误定义了列，可以点击该列将其选中，然后通过以下按钮删除：

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-caaf11d993b2aa1ac2375d0ead818454229f4e1b%2Fdefine_tables_and_columns_9.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<mark style="color:red;">**注意**</mark>：只有在选中列后才会显示该按钮。

完成文档中所有表格和列的定义后，点击“Save”按钮以启用更改并从文档中提取数据：

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-d9b39626458c7eca8899435394bce46ee807ed29%2Fdefine_tables_and_columns_8.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

系统会提取所有已定义区域的数据，并在右侧显示：

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-bce1b9d5a01319091c246da720599bc1bcfb84fe%2Fdefine_tables_and_columns_10.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

### 6. 保存并提取

定义完所有表格和列后，点击 **“Save Rules”**。

* 这会告知 DocBits 如何查找此特定供应商的表格数据。
* 下次上传同一供应商的文档时，DocBits 会使用已保存的规则自动提取表格。

<mark style="color:red;">**注意**</mark>：此训练针对特定供应商，不适用于其他供应商的文档。


---

# 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://docs.docbits.com/chinese/guan-li-yu-she-zhi/setup/document-training/training-line-fields-table-training/defining-tables-and-columns.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.
