Excel split based on count

Variables:

Preps
grafik

Groups =
(From d In ReadDT.AsEnumerable
Group d By k=d(0).toString.Trim Into grp=Group
Select g = grp.ToList()).ToList

outerlist: Groups, innerlist: Groupmembers

Splittings


Then:
tmpSegment= tmpSegment.Concat(grp).ToList
Else:
TableList = TableList.Append(tmpSegment.CopyToDataTable).toList
Last
TableList = TableList.Append(tmpSegment.CopyToDataTable).toList

So resulting List(of DataTable) can be used again within a For each e.g. for writing it to excel

Find starter help:
Main.xaml (12.1 KB)

Kindly note:
when a group has more then 10 rows, it still will become a segement within the tablelist

1 Like