I have a config file for sorting columns. Data looks like;
ColumnName | SortingRule
I have to read config, then use a for each row, and sort columns. When i do this like below;
It sorts one by one. We don’t want that. How can i achieve this?
@balupad14 Have any thougths?
@ercan.nebiler Not sure what is the Output that you expect , based on that we can provide a solution.
July 8, 2020, 8:18am
Without using for each row, you can use as below
dt_Sort = From x In dt_Sort.AsEnumerable() Order By convert.Tostring(x(“Column1")),convert.ToString(x(“Column2”)) Select x).CopyToDataTable
Using Invoke Code:
dt_Sort.DefaultView.Sort = (“Column1_name ASC, Column2_name ASC”)
dt_Sort = datatableVar.DefaultView.ToTable
Hope this works
Hi thanks for your answer.
Like i said i have a config file. Dt_Config
And a target file: Dt_Target
I will sort multiple columns. Which is dynamic. When i do this like image above, it sorts one by one. So it sorts first column. Then second. But first sort is becoming invalid. Because we sorted the other column. Clear now?
Hi can’t hardcode this. It’s have to be dynamic. There can be 3 columns, next week can be 5 columns.
July 8, 2020, 9:11am
Take a look this thread with example
Thanks for your answer.
How can i make “create table” activity’s range dynamic?
I almost made the sorting with your help. But there is a problem.
I sorted this column DESC, But it’s not seeing these as numbers i guess. What do you suggest about it?
General, i am creating this excel with excel application scope.
November 20, 2020, 12:55pm
You can use the previously mentioned approach using Invoke Code in a dynamic way as the Sort property on DataView takes a string.
“Column1_name ASC, Column2_name ASC”
You can read the config file and concatenate each sorting rule into a single string, then set it on the Sort property.
August 23, 2021, 1:45am
working beautifully! thanks