Read all data from excel and store into list

I have excel data, and read all data and stored into datatable.
Now, I need to group the one column and according to new data, I want to store into list.

THis the screen shot, And I need to group the Location column.

For this, I’m trying to use Linq group by.
List=dt.AsEnumerable().Groupby(function(r) r.Field(Of String)(“Location”).Where(function(g) g.count()>1).toList()

But unable to store into list.

@ashukla7836
Welcome to the forum

give a try on following:

Groups | List(of List(of Datarow)) =

(From d in dtData.AsEnumerable
Group d by k=d("Location").toString.Trim into grp=Group
Where grp.Count > 1
Select grp.ToList).ToList

unable to store into List variable

does mean what? What you have done, what is failing?

Create variable as List <List=New List(Of String)List=(From d in dtData.AsEnumerable
Group d by k=d(“Location”).toString.Trim into grp=Group
Where grp.Count > 1
Select grp.ToList).ToList
But IT showing error
Capture1


Groups = New List(Of List(Of DataRow)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.