I want to exclude lines from the Excel file depending on value of other file
I have to read column H value from Excel A
Read the corresponding “Exclude from value” from Excel B
If “Exclude from value” in column B is “YES”, remove the line from Excel A
Use the Read Range activity to read Excel A and Excel B into two separate DataTables, for example:
dataTableA for Excel A
dataTableB for Excel B
2. Use Assign Activity for LINQ Filtering
You can use the following LINQ query in the Assign activity to filter rows from dataTableA based on the value in dataTableB:
Assign (to filter the rows based on the condition):Assign:
To:filteredData
dataTableA.AsEnumerable().Where(Function(rowA) Not (From rowB In dataTableB.AsEnumerable()
Where rowA(“H”).ToString() = rowB(“H”).ToString() AndAlso
rowB(“Exclude from value”).ToString().Equals(“YES”)
Select rowB).Any()).CopyToDataTable()
it need not be in loop…it is already looping via linq itself
one more easier way
Use join datatable and join both based on any unique column or multiple columns …and do a left join having excel A on left
Now use filter datatable to filter rows without yes and you have your datatable ready to be written to excel…you can also filter unwanted columns in same filter activity