Linq Query for Particular Column

Hi Team,

I have one sheet, want to sort the column in ascending order and Sl No should not sort
i tried writing the code, but giving me error.
reading whole sheet and will get dt, Then

dt.DefaultView.Sort = ("[Company List] ASC")

dt1 = dt.DefaultView.ToTable

Can anyone help me on this


Hi, I would read range B2:B6 into a datatable, sort it, then write the sorted range back into the excel file. Hope that helps.

Hi, when we read range B2:B6, in the Sorttable it throws error
“Sort Data Table: In the ‘Sorting Column category’ the value for argument ‘ColumnIndex’ is not set or is invalid.”

Did you read the range before sorting? Only get/read B column, sort that, then write the sorted datatable back to excel.



and in the sort Data Table given as index 1.

Since you read one column, the index should be 0.


just skipping first column and reading all sheet data in datatable
sort.xaml (5.6 KB)

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