How to spilt datatable in excel sheet into sub-datatable using LINQ?

Can we split the excel sheet data like i have highlighted with yellow color.
Read the Complete sheet
Spit the TableName as sub tables based on Respective TemplateName.

Key is template Name
Value is Datatable

Is there any LINQ for this Scenario.

Input File -
InputData.xlsx (12.1 KB)

Thanks & Regards

subtables = excelData.
GroupBy(Function(row) row.TemplateName).
ToDictionary(Function(group) group.Key,
Function(group) group.ToList()

Try this


Can you try the following sample.

dict = dt.AsEnumerable.Select(Function(r,i) Tuple.Create(dt.AsEnumerable.Where(Function(r2,j) j<=i AndAlso r2(0).ToString<>"").Last() ,r)).GroupBy(Function(t) t.Item1.Item(0).ToString).ToDictionary(Function(g) g.Key,Function(g) g.Select(Function(t) t.item2).CopyToDataTable) (10.7 KB)

note : dict is Dictionary<string,DataTable>


Thankyou for quick response

Let me check