Skip to content

Google 表格文档内工作表操作(Google Sheets Sheet Within Document operations)#

使用此操作可以在 Google 表格中创建、更新、清除或删除工作表。有关 Google 表格节点的更多信息,请参阅 Google Sheets

🌐 Use this operation to create, update, clear or delete a sheet in a Google spreadsheet from Google Sheets. Refer to Google Sheets for more information on the Google Sheets node itself.

This node can be used as an AI tool

This node can be used to enhance the capabilities of an AI agent. When used in this way, many parameters can be set automatically, or with information directed by AI - find out more in the AI tool parameters documentation.

追加或更新行(Append or Update Row)#

使用此操作更新现有行,或在表格中未找到匹配条目时,在数据末尾添加新行。

🌐 Use this operation to update an existing row or add a new row at the end of the data if a matching entry isn't found in a sheet.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择 附加或更新行
  • 文档:选择包含你想要添加或更新行的工作表的电子表格。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 工作表:选择要添加或更新行的工作表。
    • 选择 从列表中 从下拉列表中选择工作表标题,选择 通过 URL 输入工作表的 URL,选择 通过 ID 输入 sheetId,或选择 通过名称 输入工作表标题。
    • 您可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId
  • 映射列模式
    • 手动映射每一列:为每一列输入要发送的值
    • 自动映射:n8n 会自动查找与 Google 表格中的列匹配的传入数据。在此模式下,请确保传入的数据字段与 Google 表格中的列相同。(如有需要,可在此节点之前使用 编辑字段 节点进行修改。)
    • :不映射任何数据。

选项(Options)#

  • Cell Format: Use this option to choose how to format the data in cells. Refer to Google Sheets API | CellFormat for more information.
    • Let Google Sheets format (default): n8n formats text and numbers in the cells according to Google Sheets' default settings.
    • Let n8n format: New cells in your sheet will have the same data types as the input data provided by n8n.
  • Data Location on Sheet: Use this option when you need to specify the data range on your sheet.
    • Header Row: Specify the row index that contains the column headers.
    • First Data Row: Specify the row index where the actual data starts.
  • Handling extra fields in input: When using Mapping Column Mode > Map Automatically, use this option to decide how to handle fields in the input data that don't match any existing columns in the sheet.
    • Insert in New Column(s) (default): Adds new columns for any extra data.
    • Ignore Them: Ignores extra data that don't match the existing columns.
    • Error: Throws an error and stops execution.
  • Use Append: Turn on this option to use the Google API append endpoint for adding new data rows.
    • By default, n8n appends empty rows or columns and then adds the new data. This approach can ensure data alignment but may be less efficient. Using the append endpoint can lead to better performance by minimizing the number of API calls and simplifying the process. But if the existing sheet data has inconsistencies such as gaps or breaks between rows and columns, n8n may add the new data in the wrong place, leading to misalignment issues.
    • Use this option when performance is a priority and the data structure in the sheet is consistent without gaps.

有关更多信息,请参阅 方法:spreadsheets.values.update | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.values.update | Google Sheets API documentation for more information.

追加行(Append Row)#

使用此操作在工作表数据末尾添加新行。

🌐 Use this operation to append a new row at the end of the data in a sheet.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择 添加行
  • 文档:选择一个电子表格以及你想要添加行的工作表。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 工作表:选择你想要添加一行的工作表。
    • 选择 从列表中 从下拉列表中选择工作表标题,选择 通过 URL 输入工作表的 URL,选择 通过 ID 输入 sheetId,或选择 通过名称 输入工作表标题。
    • 您可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId
  • 映射列模式
    • 手动映射每一列:在查找要更新的行时,选择要匹配的列。为每一列输入要发送的值
    • 自动映射:n8n 会自动查找与 Google 表格中的列匹配的传入数据。在此模式下,请确保传入的数据字段与 Google 表格中的列相同。(如有需要,可在此节点之前使用 编辑字段 节点进行修改。)
    • :不映射任何数据。

选项(Options)#

  • Cell Format: Use this option to choose how to format the data in cells. Refer to Google Sheets API | CellFormat for more information.
    • Let Google Sheets format (default): n8n formats text and numbers in the cells according to Google Sheets' default settings.
    • Let n8n format: New cells in your sheet will have the same data types as the input data provided by n8n.
  • Data Location on Sheet: Use this option when you need to specify the data range on your sheet.
    • Header Row: Specify the row index that contains the column headers.
    • First Data Row: Specify the row index where the actual data starts.
  • Handling extra fields in input: When using Mapping Column Mode > Map Automatically, use this option to decide how to handle fields in the input data that don't match any existing columns in the sheet.
    • Insert in New Column(s) (default): Adds new columns for any extra data.
    • Ignore Them: Ignores extra data that don't match the existing columns.
    • Error: Throws an error and stops execution.
  • Use Append: Turn on this option to use the Google API append endpoint for adding new data rows.
    • By default, n8n appends empty rows or columns and then adds the new data. This approach can ensure data alignment but may be less efficient. Using the append endpoint can lead to better performance by minimizing the number of API calls and simplifying the process. But if the existing sheet data has inconsistencies such as gaps or breaks between rows and columns, n8n may add the new data in the wrong place, leading to misalignment issues.
    • Use this option when performance is a priority and the data structure in the sheet is consistent without gaps.

有关更多信息,请参阅 方法:spreadsheets.values.append | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.values.append | Google Sheets API documentation for more information.

清除工作表(Clear a sheet)#

使用此操作清除工作表中的所有数据。

🌐 Use this operation to clear all data from a sheet.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择 清除
  • 文档:选择一个包含你想要清除数据的工作表的电子表格。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 工作表:选择要清除数据的工作表。
    • 选择 从列表中 从下拉列表中选择工作表标题,选择 通过 URL 输入工作表的 URL,选择 通过 ID 输入 sheetId,或选择 通过名称 输入工作表标题。
    • 您可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId
  • 清除:选择要从工作表中清除的数据。
    • 整个工作表:清除整个工作表的数据。开启 保留首行 可保留工作表的第一行。
    • 特定行:清除特定行的数据。也可以输入:
      • 起始行号:输入你想要清除的第一行行号。
      • 要删除的行数:输入要清除的行数。1 仅清除 起始行号 对应的行数据。
    • 特定列:清除特定列的数据。同时输入:
      • 起始列:输入要清除的第一列的字母表示法。
      • 要删除的列数:输入要清除的列数。1 仅清除 起始列 中的数据。
    • 特定范围:输入要清除数据的表格范围,使用 A1 表示法

有关更多信息,请参阅 方法:spreadsheets.values.clear | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.values.clear | Google Sheets API documentation for more information.

创建新工作表(Create a new sheet)#

使用此操作创建新的工作表。

🌐 Use this operation to create a new sheet.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择 创建
  • 文档:选择一个你想创建新工作表的电子表格。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 标题:输入新工作表的标题。

选项(Options)#

  • 隐藏:打开此选项以在界面中隐藏工作表。
  • 从右到左:启用此选项以使用从右到左的表格,而不是从左到右的表格。
  • 表格 ID:输入表格的 ID。
    • 你可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId
  • 工作表索引:默认情况下,新建的工作表是电子表格中的最后一个工作表。要覆盖此行为,请输入你希望新建工作表使用的索引。当你在特定索引添加工作表时,Google 会为所有后续工作表递增索引。有关更多信息,请参阅Sheets | SheetProperties文档。
  • 标签颜色:输入颜色的十六进制代码,或使用颜色选择器设置界面中标签的颜色。

有关更多信息,请参阅 方法:spreadsheets.batchUpdate | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.batchUpdate | Google Sheets API documentation for more information.

删除工作表(Delete a sheet)#

使用此操作可永久删除工作表。

🌐 Use this operation to permanently delete a sheet.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择删除
  • 文档:选择包含你要删除的工作表的电子表格。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 工作表:选择你想要删除的工作表。
    • 选择 从列表中 以从下拉列表中选择工作表标题,选择 按 URL 输入工作表的 URL,选择 按 ID 输入 sheetId,或选择 按名称 输入工作表的名称。
    • 您可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId

有关更多信息,请参阅 方法:spreadsheets.batchUpdate | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.batchUpdate | Google Sheets API documentation for more information.

删除行或列(Delete Rows or Columns)#

使用此操作删除工作表中的行或列。

🌐 Use this operation to delete rows or columns in a sheet.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择 删除行或列
  • 文档:选择包含你想要删除行或列的工作表的电子表格。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 工作表:选择你想要删除行或列的工作表。
    • 选择 从列表中 以从下拉列表中选择工作表标题,选择 按 URL 输入工作表的 URL,选择 按 ID 输入 sheetId,或选择 按名称 输入工作表的名称。
    • 您可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId
  • 起始行号起始列:输入要开始删除的行号或列字母。
  • 要删除的行数要删除的列数:输入要删除的行数或列数。

有关更多信息,请参阅 方法:spreadsheets.batchUpdate | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.batchUpdate | Google Sheets API documentation for more information.

获取行(Get Row(s))#

使用此操作可从工作表中读取一行或多行。

🌐 Use this operation to read one or more rows from a sheet.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择获取行
  • 文档:选择包含你想要获取行的工作表的电子表格。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 工作表:选择要读取行的工作表。
    • 选择 从列表中 以从下拉列表中选择工作表标题,选择 按 URL 输入工作表的 URL,选择 按 ID 输入 sheetId,或选择 按名称 输入工作表的名称。
    • 您可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId
  • 筛选:默认情况下,节点会返回表格中的所有行。设置筛选条件以返回有限的结果集:
    • :选择工作表中要搜索的列。
    • :输入要搜索的单元格值。你可以将输入数据参数拖到此处。如果你的筛选匹配多个行,n8n 会返回第一个结果。如果你想要所有匹配的行:
      1. 选项下,选择添加选项 > 当筛选有多个匹配项时
      2. 当筛选器有多个匹配项 更改为 返回所有匹配项

选项(Options)#

  • 工作表上的数据位置:使用此选项指定数据范围。默认情况下,n8n 会自动检测直到工作表最后一行的数据范围。
  • 输出格式:使用此选项选择 n8n 如何格式化 Google 表格返回的数据。
  • 常规范式
    • 值(未格式化)(默认):n8n 会移除货币符号和其他特殊格式。数据类型保持为数字。
    • 值(已格式化):n8n 会将值按照在 Google 表格中显示的样子呈现(例如保留逗号或货币符号),方法是将数据类型从数字转换为字符串。
    • 公式:n8n 会返回公式本身,而不会计算公式的结果。例如,如果单元格 B2 的公式是 =A2,n8n 会将 B2 的值以文本形式返回为 =A2。更多信息请参考 关于日期和时间值 | Google 表格
  • 日期格式:有关更多信息,请参阅 DateTimeRenderOption | Google 表格。 - 格式化文本(默认):如 Google 表格中显示,显示方式取决于电子表格的区域设置。例如 01/01/2024。 - 序列号:自1899年12月30日以来的天数。
  • 当筛选器有多个匹配项时:设置为返回所有匹配项以获取多个匹配项。默认情况下,只会返回第一个结果。

第一行

n8n 将 Google 表格中的第一行视为标题行,在读取所有行时不会返回它。如果你想读取第一行,请使用 选项 设置 表格中的数据位置

有关更多信息,请参阅 方法:spreadsheets.batchUpdate | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.batchUpdate | Google Sheets API documentation for more information.

更新行(Update Row)#

使用此操作可以更新表格中的现有行。此操作仅更新现有行。如果在表格中未找到匹配条目并希望追加行,请改用 追加或更新行 操作。

🌐 Use this operation to update existing row in a sheet. This operation only updates existing rows. To append rows when a matching entry isn't found in a sheet, use Append or Update Row operation instead.

请输入以下参数:

🌐 Enter these parameters:

  • 连接凭证:创建或选择现有的 Google 表格凭证
  • 资源:选择文档中的工作表
  • 操作:选择 更新行
  • 文档:选择你想要更新的工作表所在的电子表格。
    • 选择 从列表中 从下拉列表中选择电子表格标题,选择 通过 URL 输入电子表格的 URL,或选择 通过 ID 输入 spreadsheetId
    • 您可以在 Google 表格的 URL 中找到 spreadsheetIdhttps://docs.google.com/spreadsheets/d/spreadsheetId/edit#gid=0
  • 表格:选择你想要更新的表格。
    • 选择 从列表中 从下拉列表中选择工作表标题,选择 通过 URL 输入工作表的 URL,选择 通过 ID 输入 sheetId,或选择 通过名称 输入工作表标题。
    • 您可以在 Google 表格的 URL 中找到 sheetIdhttps://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid=sheetId
  • 映射列模式
    • 手动映射每一列:为每一列输入要发送的值
    • 自动映射:n8n 会自动查找与 Google 表格中的列匹配的传入数据。在此模式下,请确保传入的数据字段与 Google 表格中的列相同。(如有需要,可在此节点之前使用 编辑字段 节点进行修改。)
    • :不映射任何数据。

选项(Options)#

  • 单元格格式:使用此选项选择如何格式化单元格中的数据。更多信息请参考 Google Sheets API | CellFormat
    • 让 Google Sheets 格式化(默认):n8n 会根据 Google Sheets 的默认设置对单元格中的文本和数字进行格式化。
    • n8n 格式:你的表格中新创建的单元格将具有与 n8n 提供的输入数据相同的数据类型。
  • 工作表上的数据位置:当你需要指定工作表上的数据范围时,请使用此选项。
    • 表头行:指定包含列标题的行索引。
    • 第一数据行:指定实际数据开始的行索引。

有关更多信息,请参阅 方法:spreadsheets.batchUpdate | Google 表格 API 文档。

🌐 Refer to the Method: spreadsheets.batchUpdate | Google Sheets API documentation for more information.