Can i use list of array in filter data table Values? To check OR condition?

still getting error

better ro use the line breaks for easier reading as well

As mentioned above and pre-announced

1 Like

means , we cant resolve in c#?


kept in rows

@MitheshBolla ,
I think the keywords need to be exact when specified in C#.

Could you try the below :

(from d in DT.AsEnumerable() 
where sheetNames.Any(x => x.Contains(d["USCIS Case Status"].ToString().Trim())) 
select d).CopyToDataTable();
2 Likes

This worked bro ,For copying list of status from array to new sheet.
to delete the same list of arry in same Main sheet ie : DT?

(from d in DT.AsEnumerable()
where sheetNames.Any(x => x.Contains(d[ā€œUSCIS Case Statusā€].ToString().Trim()))
select d).CopyToDataTable();

Delete, delete is not working i checked.

@MitheshBolla , What was the method used for the Delete Operation ?

1 Like

The query which u have provided for me is to filter in dt and add to new sheet and also i need to delete those filtered rows in my main sheet.

will remove work?

(from d in DT.AsEnumerable()
where sheetNames.Any(x => x.Remove(d[ā€œUSCIS Case Statusā€].ToString().Trim()))
select d).CopyToDataTable();

@MitheshBolla ,

For Updating the Excel Sheet by Deleting the Filtered rows, we can first get the Filtered rows which does not match the condition. Meaning the reverse of the First Query. We can get the filtered rows using the below Query.

(from d in DT.AsEnumerable() 
where !sheetNames.Any(x =>x.Contains(d["USCIS Case Status"].ToString().Trim())) 
select d).CopyToDataTable();

It is the same Query, except we are using a ! operator (Not) which reverses the condition and it will able us to get the Non-Matching rows.

Now, To Update the Excel Sheet, we could first clear the entire rows in the sheet and then write the Filtered rows into it.
For clearing the entire sheet, we could use a Write Cell Activity as mentioned in the Post below.

Then use Write Range Activity to write the filtered Datatable to this Sheet Starting from A2.

1 Like

Thanks Bro ,

In this Post i had got solutions for the list below.

  1. Passing arrylist to filter data table
  2. filtering datatable with arrylist c# code
    3)deleting filtered arraylist in datatable with c# code.

Thank you all for your help.

1 Like

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