I have few keywords which needs to be filtered out from a specific single column from an excel sheet and write the output in a new excel sheet. I am using read range workbook, storing in an datatatble and using filter datatable and in that filter Datatable i am using AND function but i coudnt get the output in a new sheet
Please help me resolve this.
I have a bank statement, in that bank statement I have a specific column named âDescriptionâ from which i need to filter out the rows which is having 5 different keywords and write it into a new excel sheet
If it was a single column, you would need to utilize the âORâ function .
Syntax, which is
dt=dt_excel.AsEnumerable.where(function(x) x(âColumnName1â).ToString.ToLower.Equals(âKeyWordâ) or x(âColumnName1â).ToString.ToLower.Equals(âKeyWordâ)).copytodatatable
you have a DataTable named inputDataTable and you want to filter out rows where a specific column (letâs say âColumnNameâ) does not contain certain keywords, and then write the output to a new Excel sheet
outputDataTable = inputDataTable.AsEnumerable().Where(Function(row) Not {"Keyword1", "Keyword2", "Keyword3"}.Any(Function(keyword) row.Field(Of String)("ColumnName").Contains(keyword))).CopyToDataTable().WriteRange("OutputFilePath.xlsx", "SheetName")
AND would mean all the conditions must be true for them to be filtered out. If youâre trying to filter it out if itâs one of a certain list of values, use OR not AND. ie SomeVar = âValue1â OR SomeVar = âValue2â