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

生产力活动

上次更新日期 2025年9月3日

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

关于

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

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

Description: This examples explains how to create a workflow that gathers data from several Google spreadsheets and merges them into a new sheet, while preserving the initial data. This example presents Google Workspace activities such as Add Sheet, For Each Sheet in Spreadsheet, Read Range, and Write Range.

工作流

提示: 如果要节省时间,请在 Studio Web 中使用将 多个工作表合并到新的摘要电子表格 模板来构建此工作流。
  1. 打开 Studio Web 并创建一个新项目。
  2. Add an Add Sheet activity to your workflow. At this step, you want to add a new sheet, called Summary, to a specific spreadsheet. In the activity:
    1. 设置 Google 表格连接。
    2. 在“ 电子表格 ”字段中,浏览并选择要在其中创建新工作表的电子表格。
    3. 例如,将“工作 表名称 ”设置为“ 摘要”。 选择最适合您的用例的任何名称。


  3. Next, add a For Each Sheet in Spreadsheet activity, to iterate on the sheets you wish to merge. In the activity:
    1. 选择同一个电子表格。
    2. 在活动 主体 中,添加一个 If 活动。 按如下方式配置活动:
      1. 设置迭代的 条件 。 单击 加号 图标以选择“ 使用变量”。
      2. 将条件设置为: 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:
    1. 选择电子表格。
    2. 对于“ 范围 ” 字段,单击 号图标以选择“ 使用变量”,然后选择 CurrentItem
    3. 将“ 含标头 ” 字段设置为 “True”
    4. 将“ 读取内容” 字段设置为“ ”。


  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. 添加一个 “ 日志消息” 活动,以记录已将第一个工作表 (CurrentItem) 添加到 “ Summary ” 工作表 (New sheet name) 中。 此步骤是可选的。
    1. 按如下方式配置“ 消息” 字段:


  7. 接下来,添加另一个“ If ”活动,并设置一个条件,以确定接下来要读取的工作表是否与“ Summary ”工作表不同。 在此步骤中,我们将复制其他工作表,不包括标头。
    1. 按如下方式配置 条件CurrentItemIndex 变量 大于 1


  8. Set the Then branch. Add a Read Range activity to read through the sheets in the spreadsheet:
    1. 选择电子表格。
    2. 对于 范围 字段,选择 使用变量 ,然后选择 CurrentItem 变量。
    3. 将“ 含标头 ” 字段设置为 “True”
    4. 将“ 读取内容” 字段设置为“ ”。


  9. Next, add a Write Range activity, to write the data read into the Summary sheet.
    1. 选择电子表格。
    2. 对于 范围 字段,选择初始 添加工作表 活动的 New sheet name 变量。
    3. 将“ 包含标头 ” 字段设置为“ False”。
    4. Set the How to write field to Append. To learn more about appending, see the activity's documentation.
    5. 对于“ 写入 内容” 字段,选择“ 读取范围 ” 活动的输出变量。


  10. 接下来,在“ Then ”分支下添加一个“ 日志消息” 活动,以记录所有工作表都已附加到“ Summary ”工作表中。此步骤是可选的。


  11. 您已完成操作,可以运行项目了!
  • 关于
  • 工作流

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2025 UiPath。保留所有权利。