英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论