They are list of values, the list of values should be filtered in a particular column. How to do that
there are 4 values , with that values I have to filter a column in a excel sheet
Filter in same column or different columns?
if same column
dt.Select("column1='Value1' or column1='Value2' or column1='Value3' or column1='Value4'").CopyToDataTable()
if different column
dt.Select("column1='Value1' and column2='Value2' and column3='Value3' and column4='Value4'").CopyToDataTable()
diff sheet diff column
filtered values are dynamic, they are stored in a variable.
dt.Select(“column1='”+strValue1+“’ and column2='”+strValue2+“’ and column3='”+strValue3+“’ and column4='”+strValue4+“'”).CopyToDataTable()
Regards,
Arivu
sheet1.xlsx (10.3 KB)
col2 in sheet1 should be filtered in sheet2
sheet1 col2 values are also filtered values, they are filtered based on col3, if col3 has -1,1,0 then it should filter. I got logic to filter col3 but I cant filter the list of values from col2 sheet1 in col2 expected sheet
There is no “Sheet2” in your excel
(From p in dtSheet1.Select() where( From q in dtSheet2.Select() where q(“ColumnName”).Equals(p(“ColumnName”)) Select q).ToArray.Count>1 Select p).ToArray.CopyToDataTable()
Regards,
Arivu
iam sorry its Expected sheet
(From p in dtSheet1.Select() where(From q in dtExpected.Select() where q("col2").Equals(p("col2")) Select q).ToArray.Count>1 Select p).ToArray.CopyToDataTable()
Regards,
Arivu
error source contains no datarows but dtsheet1 and dtexpected contains values
can you share the screenshot and error message
have you read both the datatable? can you share the xaml file
Try below query
(From p in dtSheet1.Select() where(From q in dtExpected.Select() where q("col2").Equals(p("col2")) Select q).ToArray.Count>0 Select p).ToArray.CopyToDataTable()
Regards,
Arivu
Same error iam getting
Hey @anjani_priya
Can you Provide the input file for Better understanding
and mention your query below of file how you the want output .
sheet1.xlsx (10.3 KB)
col2 in sheet1 should be filtered in expected sheet col2
I cant filter the list of values from col2 sheet1 in col2 expected sheet

