Hi Team,
How Can i reorder columns in DataTable in UiPath, and which approach is recommended?
Thanks!
Hi Team,
How Can i reorder columns in DataTable in UiPath, and which approach is recommended?
Thanks!
Hi @Bob01,
dt=dt.Defaultview.ToTable(False,{“col1”,“col2”,“col3”})
This reorders columns in the specified order and keeps all rows. i think it is simple and recommended approach.
regards,
Aarya Singh
Hi @Bob01,
You can reorder columns by recreating the DataTable with the desired column order using DefaultView.ToTable(False,column)
It is working or not ?
Hi @Bob01 ,
You can reorder columns either by using SetOrdinal for small changes, or recreate the DataTable in one step using dt = dt.DefaultView.ToTable(False, {“Col3”,“Col1”,“Col2”}) when you want a full reorder.
You can do it using linq the
dt = dt.DefaultView.ToTable(False, {“Col4Name”,“Col3Name”,“Col2Name”}) where False will not remove duplicates, True will remove duplicates. You can add true or false based on your requirement. You can keep any order of column names you want..
Hi @Bob01
dt.Columns("ColumnName").SetOrdinal(index) to move a column by index.This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.