> 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/action-shi-yong-zhi-nan/blocks/for.md).

# For

For 是一个用于将一组操作按照预先设定的次数重复执行的代码块。该循环使用一个默认名为 $loopIndex 的计数变量来跟踪循环的进度。

🎥 观看更多教程视频：[点击这里](https://youtu.be/4O4dPC-CNHM)。

#### For 循环中的配置参数：

* 🟢 Start：循环变量 `$loopIndex` 的起始值。
* 🔴 End：结束值。当 `$loopIndex` 达到 `End - 1` 时，循环将停止。
* ⚡ Increase by：每次循环完成后 `$loopIndex` 的增量（增加的步长）。

#### 实际示例：结合 For 循环读取整个 Excel 文件的数据

假设您有一个名为 `test.xlsx` 的 Excel 文件，您需要配置脚本以读取该文件 B 列中的全部数据。您可以将 For 循环与系统变量 `$inputExcelTotalRows` 结合使用，如下所示：

🎥 观看更多教程视频：[点击这里](https://youtu.be/kbh7muMDGtI)。

<figure><img src="https://1806980278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiDNNiVZHPKSIcyshmOTB%2Fuploads%2Fgit-blob-316a30d10998c5e707a6b99682e46261e6afeffe%2Fcb-01.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1806980278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiDNNiVZHPKSIcyshmOTB%2Fuploads%2Fgit-blob-9a20b8295d7aaa80342ae0291e3ae03318165302%2Fcb-01b.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1806980278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiDNNiVZHPKSIcyshmOTB%2Fuploads%2Fgit-blob-c07b81a18e7038bcf31d9e44367767ffb0675fe8%2Fcb-01c.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# 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.gpmautomate.com/automate-zh/action-shi-yong-zhi-nan/blocks/for.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.
