UiPath Documentation
studiox
2023.10
false

StudioX 用户指南

上次更新日期 2026年4月30日

教程:遍历表中的行

在本教程中,我们将创建一个自动化操作以对 Excel 表格中尚无“交易编号”值的每一行重复以下工作流:

  1. 复制“现金输入”列单元格中的值。
  2. 将值粘贴到桌面应用程序的字段中。
  3. 复制桌面应用程序中的交易编号。
  4. 将值粘贴到“交易编号”列的单元格中。
  5. 单击桌面应用程序中的按钮以提交数据。

我们将创建一个项目,首先添加一个“使用 Excel 文件”活动,以指明要使用的 Excel 文件。在此活动内,我们将添加一个“遍历 Excel 行”活动,以指明在我们遍历每行时应针对每一行重复执行这些活动。因为我们只希望为 Excel 文件中不包含“交易编号” 值的行执行自动化,所以我们将在“遍历 Excel 行” 活动中添加一个“IF 条件”活动,以指明要自动化的活动只应对满足“交易编号”单元格为空这一条件的行。

  1. 设置项目并获取必要的文件。
    1. 使用默认设置创建一个新的空白项目
    2. 使用此页面底部的按钮,通过本教程中的自动化项目下载并提取存档。将“DoubleUI.xlsx”文件复制到您的项目文件夹,然后双击“DoubleUI.exe”文件以打开 DoubleUI 应用程序。
  2. 将 Excel 文件添加到项目中。
    1. Click Add Activity 文档图像 in the Designer panel, and then find the Use Excel File activity in the search box at the top of the screen and select it. A Use Excel File activity is added to the Designer panel.
    2. 在活动中:
      • Click Browse 文档图像 next to the Excel file field, and then browse to and select the file DoubleUI.xlsx

      • 在“引用为”字段中,输入 UID

        您已指明将使用自动化中称为“UID”的文件“DoubleUI.xlsx”。

  3. 遍历 Excel 文件中的行。
    1. Click Add Activity 文档图像 inside Use Excel File, and then, in the Common Scenarios section of the search box at the top of the screen, click Repeat actions for rows in Excel range. A For Each Excel Row activity is added to the Designer panel inside the Use Excel File activity.

    2. In the For Each Excel Row activity, click Plus 文档图像 on the right side of the In range field, and then select UID > Input [Sheet] > Transactions[Table] to select the table Transactions from the Input sheet of the file UID. Your selection is displayed in the In range field as [UID] Transactions.

      您已指明要迭代访问“Transactions”表格中的行。

  4. 添加执行活动要满足的条件。
    1. Click Add Activity 文档图像 inside the For Each Excel Row activity and then, in the search box at the top of the screen, locate and click If. An If activity is added in the Use Application/Browser activity.
    2. In the If activity, select 文档图像 Open in Advanced Editor next to the Condition field to open the Condition Builder.
    3. 在条件生成器中,添加条件“如果当前行中的事务号为空”:
      • Click Plus 文档图像 on the right side of the field on the left, and then select CurrentRow > Transaction # to select the Transaction # value from the current row you are iterating through as the value to evaluate in the condition.

      • 从中间的下拉菜单中,选择“为空”

        针对满足此条件的行,将执行您在 If 活动的 Then 分支中添加的活动。

  5. 如果满足条件,请添加桌面应用程序和要在其中执行的活动。
    1. Click Add Activity 文档图像 inside the Then branch of the If activity and then, in the search box at the top of the screen, locate and click Use Application/Browser. A Use Application/Browser activity is added in the Then branch of the If activity.

    2. 在“使用应用程序/浏览器”活动中,单击“配置窗口”,然后将鼠标指针移动到 DoubleUI 窗口内。该窗口突出显示后,在 DoubleUI 中单击任意位置。

      “使用应用程序/浏览器”活动已更新,并且该活动内出现应用程序窗口的屏幕截图。

    3. Click Add Activity 文档图像 inside the Use Application/Browser activity and then, in the search box at the top of the screen, locate and click Type Into. A Type Into activity is added in the Use Application/Browser activity.

    4. 在“键入到”活动中:

      • 单击“在屏幕上指定目标”,然后将鼠标指针移到 DoubleUI.exe 应用程序中的“Cash In”字段上,并在该字段突出显示后单击该字段。文本字段将被标识为目标,其旁边的“Cash In”标签被标识为锚点。在“选择选项”窗口中,单击“确认”以保存选择。目标和锚点的图像显示在“键入到”活动中。

        您已经表明要在 DoubleUI.exe 应用程序中键入“Cash In”字段。

      • Click Plus 文档图像 on the right side of the Type this field, and then select CurrentRow > Cash In to select the Cash In value from the current row you are iterating through as the value to type.

    5. Click Add Activity 文档图像 inside the Use Application/Browser activity below the Type Into activity and then, in the search box at the top of the screen, locate and click Get Text. A Get Text activity is added in the Use Application/Browser activity after the Type Into activity.

    6. 在“获取文本”活动中:

      • 单击“在屏幕上指定目标”,然后将鼠标指针移到 DoubleUI.exe 应用程序中的“Transaction #”值上,当该值突出显示时,单击该值。Transaction # 值被标识为目标,并且其旁边的标签被标识为锚点。在“选择选项”窗口中单击“确认”以保存选择。目标和锚点的图像显示在“获取文本”活动中。

        您已指明要从 DoubleUI.exe 应用程序中复制“Transaction #”的值。

      • Click Plus 文档图像 on the right side of the Save to field, and then select CurrentRow > Transaction # to select the Transaction # column on the current row you are iterating through as the cell where to paste the value copied from the application.

    7. Click Add Activity 文档图像 inside the Use Application/Browser activity below the Get Text activity and then, in the search box at the top of the screen, locate and select Click.

      “使用应用程序/浏览器”活动中“获取文本”活动之后的“点击”活动。

    8. 在“点击”活动中,单击“在屏幕上指定目标”,然后将鼠标指针移至 DoubleUI.exe 应用程序中的“接受”按钮上,并在该按钮突出显示后,单击该按钮。“接受”按钮将被标识为目标,“取消”按钮被标识为锚点。在“选择选项”窗口中,单击“确认”以保存选择。目标和锚点的图像显示在“点击”活动中。

      您已指明要单击 DoubleUI.exe 应用程序中的“接受”按钮。

    9. 在 StudioX 功能区中单击“保存” ,以保存自动化,然后单击“运行”来执行自动化。系统会将 UID 表中每一行中没有“交易编号”值的“兑现”值输入到 DoubleUI 应用程序中,而“交易编号”则来自 DoubleUI 应用程序值将复制到 UID 表中的每一行。下载示例

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新