UiPath Documentation
activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。

生产力活动

上次更新日期 2026年5月12日

将多张工作表合并到一个新的摘要 工作表中

关于

摘要:将多张工作表中的数据连接到一个新的 Google 电子表格中。系统不会删除初始数据。

应用程序:Google 云端硬盘、Google 表格

说明:此示例说明了如何创建用于从多个 Google 电子表格收集数据并将其合并到一个新工作表中,同时保留初始数据的工作流。此示例介绍 Google Workspace 活动,例如“添加工作表”“遍历电子表格中的工作表”“读取范围”“写入范围”

工作流

提示:

如果您想节省时间,请使用 Studio Web 中的将多张工作表合并为新的摘要电子表格模板来构建此工作流。

  1. 打开 Studio Web 并创建一个新项目。

  2. “添加工作表”活动添加到工作流中。在此步骤中,您想要将一个名为“Summary”的新工作表添加到特定的电子表格。在活动中:

    • 设置 Google 表格连接。
    • “电子表格”字段中,浏览并选择要在其中创建新工作表的电子表格。
    • 例如,将“工作表名称”设置为“摘要” 。选择最适合您的用例的名称。

  3. 接下来,添加一个“遍历电子表格中的工作表”活动,以遍历要合并的工作表。在活动中:

    • 选择同一个电子表格。
    • 在活动的“主体”中,添加一个“If 条件”活动。按如下方式配置活动:
      • 设置迭代的“条件” 。单击加号图标以选择(可选)使用变量
      • 将条件设置为: CurrentItemIndex=1

4. Next, add an activity for the Then branch of If. This is the activity to execute in case the condition is true. Add a Read Range activity. Its purpose is to use the first sheet headers in the Summary range and copy its data. Configure it as follows:

  • 选择电子表格。
  • 对于“范围” 字段,单击加号图标以选择“使用变量” ,然后选择CurrentItem
  • 含标头字段设置为True
  • “读取内容”字段设置为“值”

5. Right after the Read Range activity (still under the Then branch), add a Write Range activity and configure it as follows:

  1. 选择同一个电子表格。
  2. 对于范围字段,单击加号图标以选择使用变量,然后选择添加工作表活动的输出变量。
  3. “包含标头”字段设置为“True”
  4. “写入方式”字段设置为覆盖
  5. “写入内容”字段中,选择读取范围活动的输出变量。

6. Add a Log Message activity to record that the first sheet (CurrentItem) has been added to the Summary sheet (New sheet name). This step is optional.

  • 按如下方式配置“消息”字段:

7. Next, add another If activity and set a condition that determines if the next sheets to be read are different than the Summary sheet. At this step, we copy the other sheets, excluding the headers.

  • 按如下方式配置条件CurrentItemIndex变量大于1

8. Set the Then branch. Add a Read Range activity to read through the sheets in the spreadsheet:

  • 选择电子表格。
  • 对于“范围”字段,选择“使用变量” ,然后选择CurrentItem变量。
  • 含标头字段设置为True
  • “读取内容”字段设置为“值”

9. Next, add a Write Range activity, to write the data read into the Summary sheet.

  • 选择电子表格。
  • 对于“范围”字段,选择初始“添加工作表”活动的New sheet name变量。
  • “包含标头”字段设置为“False”
  • “如何写入”字段设置为“附加” 。要了解有关附加的更多信息,请参阅活动的文档
  • “写入内容”字段中,选择读取范围活动的输出变量。

10. Next, add a Log Message activity, still under the Then branch, to record that all the sheets have been appended into the Summary sheet. This step is optional.

11. 您已完成,可以运行项目了!

  • 关于
  • 工作流

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新