Linq query for deleteing rows

DELETE ROWS.xlsx (9.9 KB)
i want linq query to delete some rows…the problem is in sheet1 and expected result is in sheet 2.
please watch carefully not all rows are empty.

Deletion can be realized as a filtering
we could filter where ID And Name Column is empty

When deletion is really needed then LINQ for row index calculations can be used
Deletion we could do with remove datarow Activity in combination with a for each over the index list.We sort the index list Descending and are not confused on the changing rows count after a row deletion

Hi @Hemant_Deshmukh

dt = dt.AsEnumerable().Where(Function(row) Not String.IsNullOrWhiteSpace(row("ID").ToString()) AndAlso Not String.IsNullOrWhiteSpace(row("NAME").ToString())).CopyToDataTable()

Hope it helps!!

Hi @Hemant_Deshmukh

You can use this query

DataTable.AsEnumerable().Where(Function(row) Not String.IsNullOrWhiteSpace(row.Field(Of String)("NAME"))).CopyToDataTable()


dt_excel.AsEnumerable.Where(function(x) Not String.IsNullOrEmpty(x(1).ToString)).CopyToDataTable