需要在UiPath中的LINQ Vlookup中更改查找列。

huangapple go评论73阅读模式
英文:

Need to change the lookup column in LINQ Vlookup in UiPath

问题

我在第11列中有查找值。在执行下面的代码时,它选择了输入Excel文件的第一列。所以我需要将查找值从第一列更改为第三列(例如,我的源查找值在第三列)。在下面的代码中,我需要更改哪一列。

(From d In dtData1.AsEnumerable
Let check = dtData2.AsEnumerable.Where(Function (r)r(0).toString.Trim.Equals(d(0).toString.Trim)).toList
Let c2 = If(check.Count() > 0, check(0)(0), "")
Let ra = {d(0), c2}
Select dtResult.Rows.Add(ra)).CopyToDataTable
英文:

I have the lookup value in the 11 column. While executing the below code it picking up the first column of my input excel file. So i need to change the lookup value from 1st column to 3rd column(example my source lookup value is in 3rd coulmn).in the below code where i need to change the column.

(From d In dtData1.AsEnumerable
Let check = dtData2.AsEnumerable.Where(Function (r)r(0).toString.Trim.Equals(d(0).toString.Trim)).toList
Let c2 = If(check.Count() > 0, check(0)(0), "")
Let ra = {d(0), c2}
Select dtResult.Rows.Add(ra)).CopyToDataTable

答案1

得分: 1

假设dtData2是您要在其中查找第三列值的表格,请使用以下代码:

(From d In dtData1.AsEnumerable
Let check = dtData2.AsEnumerable.Where(Function (r) r(2).ToString().Trim().Equals(d(0).ToString().Trim())).ToList()
Let c2 = If(check.Count() > 0, check(0)(0), "")
Let ra = {d(0), c2}
Select dtResult.Rows.Add(ra)).CopyToDataTable()

在上面的代码中,我将r(0).ToString更改为r(2).ToString。
我建议使用列名而不是索引,这样您可以更好地理解LINQ。

英文:

Assuming that dtData2 is your table where you want to lookup the value in 3rd column then use the below code

(From d In dtData1.AsEnumerable
Let check = dtData2.AsEnumerable.Where(Function (r)r(2).toString.Trim.Equals(d(0).toString.Trim)).toList
Let c2 = If(check.Count() > 0, check(0)(0), "")
Let ra = {d(0), c2}
Select dtResult.Rows.Add(ra)).CopyToDataTable

In the above code, I have change r(0).ToString to r(2).ToString.
I would recommend using a column name instead of an index so that you get a better understanding of LINQ.

huangapple
  • 本文由 发表于 2023年8月9日 07:45:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76863760.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定