> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/file-and-folder/read-excel-file.md).

# 读取Excel文件

读取 Excel 文件是从 Excel 文件 (`.xlsx` 或 `.xls`) 中提取特定单元格的值的操作，基于指定的行和列位置，然后将该值保存到一个输出变量中。

#### 配置参数：

* 文件路径：指向需要读取数据的 Excel 文件的绝对路径（例如：`D:\GPM\data.xlsx`）。
* 工作表索引：需要读取的工作表在 Excel 文件中的位置，从 0 开始计算 *(第一个工作表为 `0`，第二个工作表为 `1`...)*。
* 列名或索引：包含需要提取数据的列的位置。您可以通过两种方式填写：
  * 按字母字符名称：`A`，`B`，`C`，`D`...
  * 按索引数字，从 1 开始计算 *(列 A 为 `1`，列 B 为 `2`...)*。
* 行索引：包含需要提取数据的行的位置，从 1 开始计算 *(第一行是标题行或数据行 1 为 `1`，下一行为 `2`...)*。
* 输出变量：保存从该 Excel 单元格读取的值的变量名称。

#### 实际示例：从 Excel 文件中读取账户和密码以进行登录

假设您有一个 Excel 文件，包含存储在路径 `D:\GPM\accounts.xlsx` 的账户列表。第一个工作表的结构（工作表索引 = 0）如下：

* 列 A（列 1）：包含用户名
* 列 B（列 2）：包含密码

您想要读取第 2 行（标题行之后的第一行数据）的账户数据：

* 配置获取用户名的方法：
  * 文件路径：`D:\GPM\accounts.xlsx`
  * 工作表索引：`0`
  * 列名或索引：`A`（或填写 `1`）
  * 行索引：`2`
  * 输出变量：`$username`
* 配置获取密码的方法：您在下面创建一个类似的操作：
  * 参数保持不变，只需将列名或索引更改为 `B`（或填写 `2`），并将输出变量设置为 `$password`。

结果：系统将准确提取单元格 `A2` 的值到变量 `$username`，并将单元格 `B2` 的值到变量 `$password`。然后，您可以将这两个变量传递给浏览器交互操作以进行自动登录。


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/file-and-folder/read-excel-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
