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

生产力活动

上次更新日期 2026年3月6日

验证 Excel 工作簿数据

下面的示例说明了如何使用 Excel 活动来分析和验证库存,以及通知用户补货需求。该示例提供了诸如“读取行”“读取单元格”“读取单元格公式”之类的活动。您可以在UiPath.Excel.Activities包的“Workbook”部分下找到这些活动。

备注:

下载并提取本示例中的项目存档,然后将文件“stock.xlsx”复制到您的项目文件夹。

此自动化流程的构建方法如下:

  1. 打开 Studio ,创建一个新“流程”

  2. 将“序列”容器拖动至“工作流设计器”

    • 创建以下变量:
    变量名称变量类型默认值
    headerSystem.Collections.Generic.IEnumerable<System.Object>不适用
    productSystem.Collections.Generic.IEnumerable<System.Object>不适用
    orderList数据表不适用
    indexInt32不适用
  3. 将“读取行”活动拖动至“序列”容器中。

    • 在“文档路径”字段中添加表达式 "stock.xlsx"
    • 在“工作表名称”字段中添加值 "Bucharest"
    • 在“起始单元格”字段中添加值 "A1"
    • In the Properties panel, add the variable header in the Result field.
  4. 将另一个“读取行”活动拖动至上一个“读取行”活动下方。

    • 在“文档路径”字段中添加表达式 "stock.xlsx"
    • 在“工作表名称”字段中添加值 "Bucharest"
    • 在“起始单元格”字段中添加值 "A2"
    • In the Properties panel, add the variable product in the Result field.
  5. 将“分配”活动拖动至“读取行”活动下方。

    • 在“收件人”字段中添加“index”变量。
    • Add the value 2 in the Value field.
  6. 将“先条件循环”活动拖动至“分配”活动下方。

    • 在“条件”字段中添加表达式“product.First.ToString.Length > 0”。
    • 选择“序列”容器并创建以下变量:
    变量名称变量类型默认值
    requiredAmountDouble不适用
  7. 将“读取单元格”活动拖动至“先条件循环”活动的“序列”容器内。

    • 在“文档路径”字段中添加表达式 "stock.xlsx"
    • 在“工作表名称”字段中添加值 "Bucharest"
    • 在“起始单元格”字段中添加值 "D" + index.ToString
    • In the Properties panel, add the variable requiredAmount in the Result field.
  8. 将“If 条件”活动拖动至“读取行”活动下方。

    • 在“条件”字段中添加表达式“requiredAmount > 0”。
  9. 将“序列”容器拖动到“If 条件”活动的“Then”字段中。

    • 创建以下变量:
    变量名称变量类型默认值
    amountFormula字符串不适用
    index2字符串不适用
  10. 将“读取单元格公式”活动拖动至“Then”字段的“序列”容器内。

    • 在“文档路径”字段中添加表达式 "stock.xlsx"
    • 在“工作表名称”字段中添加值 "Bucharest"
    • 在“起始单元格”字段中添加值 "D2"
    • In the Properties panel, add the variable amountFormula in the Result field.
  11. 将“消息框”活动拖动至“读取单元格公式”活动下方。

    • 在“文本”字段中添加表达式 "According to the formula (" + amountFormula + ") you have to order " + requiredAmount.ToString + " more " + product.ElementAt(0).ToString + " from " + product.ElementAt(1).ToString
  12. 将“分配”活动拖动至“If 条件”活动下方。

    • 在“收件人”字段中添加“index”变量。
    • 在“值”字段添加表达式 index + 1
  13. 将“读取行”活动拖动至“分配”活动下方。

  • 在“文档路径”字段中添加表达式 "stock.xlsx"
  • 在“工作表名称”字段中添加值 "Bucharest"
  • 在“起始单元格”字段中添加值 "A" + index.ToString
  • In the Properties panel, add the variable product in the Result field.

您的工作流应如下所示:

docs image

  1. 运行流程。系统将分析、验证 Excel 文件,并显示一条消息,通知用户所需的更改。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新