Before You have to Clone the headers from readDt and pass instead of resultdt in below expression
Dt–>InputDt
ResulDt–>Inputdt.clone
(From d In Dt.AsEnumerable Group d By k=d(“Servicefall”).toString.Trim Into grp=Group Let ra =New Object(){k} Select resultDT.Rows.Add(ra)).CopyToDataTable
May I ask what do you intend to display/write range to your excel? The reason I’m asking is I don’t see any other column or aggregation/computation on your LINQ query as a result of your grouping. And as far as I know, what you’ll get will be a result similar to a “Select Distinct Servicefall” query.
If you’re intent is to display all rows but grouped, it may be achieved by just sorting a column in your Data table. Or iterate thru the result of your LINQ query as it is a List of DataTables, to get each grouping.
I have implemented this, but now I only get the values from the column “Service case” where I need the whole row and all ID’s are in the new table, not the grouped ones.
if you want them all in just 1 data table, then use Merge. However, as I pointed out, this will just look like your “original” data table sorted by “Servicefall”
Can someone tell me what the difference is between the For Each activity and a loop in a FlowChart?
Basically, I thought you could just replace them with my solution.