I’m using this method to filter my excel sheet
(
From row In out_excel1_DataTable
Group row By a = row(“Column B”).ToString Into grp = Group
Select grp.First
).CopyToDataTable
“column B” contains bunch of unique invoice number, suppose (invoice number = 1234, has 50 rows) and every single row has a price column, we just need single row data of single invoice but we need sum of price from the 50 rows.
var result = (from row in YourTable
group row by new {row.InvoiceNumber}
into grp
select new
{
grp.Key.InvoiceNumber,
Quantity = grp.Sum(row => row.IncidentCost)
}).ToList();
dtResults = (From dte In dtTable.AsEnumerable
Group dte By col1=dte(2).ToString.Trim Into Group
Select dtResults.Rows.Add({col1, Group.Sum(Function (x) CInt(x(1).toString.Trim))})).CopyToDataTable
Note: Give the correct index of the column in the highlighted (in Bold) places.