Regarding Excel automation using Collections

I have a collection of type dictionary, in which two column value of excel is stored as key value pair
if key value pair matches to values that stored in another datatable then i have to delete those rows from the datatable. how to achieve this
thanks in advance

1 Like

hope these steps could help you resolve this
–hope you have a dictionary variable ready named in_dictionary of default value in the variable panel new Dictionary(of string)(string)
–and a datatable as well named outdt
–meanwhile create a list variable of type list(of integer) named in_list with default value of new list(of integer)
–now use a for each loop activity and pass the above dictionary variable as input and change the type argument as new Dictionary(of string)(string)
–inside the loop use a for each row loop and pass the outdt variable as input
–inside this for each row loop use a if condition like this
and if the condition passes it will go to THEN part where can use a add to collection activity in which mention the collection as in_list and item property with value as
outdt.Rows.IndexOf(row) and in the type argument property mention as int32
–now after this add to collection activity use a break activity

–then next to the for each activity (not for each row, its for each) use again a for each loop activity and pass the input as in_list and change the type argument as int32 in the property panel
–inside the loop use a activity called Remove datarow activity where mention the rowindex property as item and datatable name with outdt as input
–now this will remove all the rows which are stored in the in_list that we obtained from previous for each loop

simple isn’t it
hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @amit.chaudhary

1 Like

in this line item is key value pair, how can i specify from which column i am matching key and from which column i am matching value?

1 Like

That’s a good question
In that case we can mention the condition like this
in if condition
item.Keys.ToString.Contains(row(“yourcolumnname”).ToString) AND item.Values.ToString.Contains(row(“yourcolumnname”).ToString)

This will validate both the key and item at the same time
Cheers @amit.chaudhary


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.