> 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/google-service/write-google-sheet.md).

# 写入谷歌表格

写入谷歌表格是指命令脚本自动连接到您的Google Drive账户，以覆盖或插入新内容到在线Google Sheets文件中的特定单元格。

#### 配置参数：

* 凭证文件：选择Google账户的凭证文件（`.json`文件）。这是授权GPM Automate连接、验证并执行将内容写入您的Google表格的安全凭证。
  * *创建文件的指南*：请查看此处的视频指导：
* 文件ID：需要交互的Google Sheets文件的唯一标识符（从文件的URL路径中`/d/`和`/edit`之间的字符串获取）。
* 表单ID：需要写入内容的工作表的序号（从左到右，第一张表从`0`开始）。
* 列名称或索引：指定需要写入数据的列位置。您可以输入字母（例如：`A`，`B`，`C`...）或输入索引的序号（例如：`1`对应列A）。
* 行索引：需要写入数据的行的序号，从`1`开始计算。
* 值：您希望填入目标单元格的文本、数字或来自GPM Automate变量的值。

#### 实际示例：在运行完成后自动更新账户状态

当您进行账户养护或发布时，在一个Profile成功完成任务后，您希望在Google表格的状态列中写入“Live”或“成功”以便于跟踪：

* 配置写入C2单元格的方法：
  * 凭证文件：选择到已配置的`client_secret_....json`文件的路径。
  * 文件ID：输入您的Sheet文件ID。
  * 表单ID：`0`（写入第一张表）。
  * 列名称或索引：填写`C`（或填写`3`）。
  * 行索引：填写`2`。
  * 值：填写“Live”（或传递状态变量`$status`）。
* 结果：GPM Automate将立即同步并快速将“Live”直接填写到您在线Google表格的C2单元格中，无需打开Docs浏览器。


---

# 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/google-service/write-google-sheet.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.
