Data table Column reorder

Dear Forum members

My problem is that i am creating data table based on selected excel file, now i have data table with many columns and i want to reorder the column sequence.
Because of column name may change if i selected different excel file so that setOrdinal is not working, but every time i need the column sequence same. like first date,customer,product etc.

please help me out.

Check this below link, @Yankit_singh

Hope this may help you :slight_smile:

1 Like

maybe you can provide some more details on how the columnname of the datatable is retrievable / deriveable when it is changed / unpredictable.

Kindly note:

  • using SetOrdinal can also be done by using the DataColumnIndex
    grafik

Another usefull approach is:

  • Variables:
    grafik
    • define an array with the sequence of the reoredered columns, ommit unneded columns
  • use the default view method:
    grafik

Thankx buddy

but my problem is that…
for exp i have column name…
A B C D
and next time sequence may be
C A B D
and next time column name can replace like
A–> Z, B–>X, C–>V, D–>N

but it contain same data associated with column in each case,either in 1 or 2nd and 3rd case.

Expected column sequence like
A B C D every time

Thankx in advance

Ok, understood so far.
The technical things on how to reorder columns are cleared so far.

So, now it to find out on how a column can be detected. As it can not be done on the column name you can have a check if evaluating the cell contents cn give some hints.

Example: Regardless of columnname (A,X,D, DueDate) if we can validate that the all values are matching a date format (eg. 12/02/2020) and it is the only column with date in the dt, then we can handle this.

Similar find other validations rules e.g. Number only, Letters only, Numbers with a length of X.

Kindly note: as we do not know the details to your case / data we only can provide general suggestions. But if the detect-ByValueValidations Approach would work, we can help you to setup such validations