gpt4 book ai didi

excel - uipath "for each"耗时

转载 作者:行者123 更新时间:2023-12-04 20:52:53 29 4
gpt4 key购买 nike

我在我的 UIPath 项目中实现了一个普通的“for each”循环(不是每行特定的 excel)。

for-each 循环使用以前从 excel 文件中检索到的数据查看数据表。

然后,for-each 循环在 Data 中迭代,并在其后加上 if-else。

可以说如下:

for each item in dataTable:

if (content of item == "10")
{
write cell: "Test" into A + index.ToString()
// leads for instance to writing into excel column 'A1'
}

else
{ write cell: "ElseTest" into for C + index.ToString() }

- 我使用语法只是为了演示目的.. :D

-> 所以问题是:
写入单元格需要花费大量时间,否则在 if 和 elses 中输出带有随机文本的 MessageBox 只需几毫秒,因此 for-each-loop 不会成为问题......

我在打开任务管理器的情况下运行了该过程,发现 Excel 启动了,CPU 百分比急剧增加,立即跳到 0% ......同样的情况再次发生,对于循环中的每次迭代。

这是为什么?
有没有 更优化的方式要做到这一点?

我需要 for-each 结构,因为我需要检查它在单元格内是值 1 还是值 2...

Picture of my Excel Scope

最佳答案

一种可能的选择是使用 Read Range事件,操纵DataTable对象本身,然后最后使用 Write Range 将所述对象写回相同的范围事件。

这是一个例子。我的工作表包含 100 行,A 列中的所有数字都是从 1 到 100。只要单元格中有“1”,数据就会被覆盖(在 DataTable 对象中)。

enter image description here

关于excel - uipath "for each"耗时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200792/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com