I have an excel and I have two column and I have to pick third column on the basis of that.
If my first column is Blank, and second column is “N” then I will not pick the third column value. However, if first column is not blank and second column is “Y” then I have to pick the third column value.
How to do that ? any help?
Filtering two excel column
Hi there @Chirag1991,
You can read the DataSet in as a DataTable, then filter it with the below expression:
YourDataTable - YourDataTable.AsEnumerable.Where(Function (drRows) Not(String.IsNullOrWhiteSpace(drRows.Item("Column1Name").ToString)) AND drRows.item("Column2Name").ToString.Tolower.Trim.Equals("y")).CopyToDataTable
The above will convert the DataTable to an iEnumerable of DataRows, which then has a Where method applied, filtering based on whether the first column ispopulated and the second column be “Y”.
Finally, the end result will be copied back to the original DataTable.
Thanks in advance,