How to reverse all the columns in an Excel file

Hi All,

I need to reverse all the columns in an Excel file but don’t know how to do, please help me.

Regards,
Ruhul.

Hy @Alom_R,

Data Tables variables: dt_Reverse, dt_Original

Thry this line of code:
dt_Reverse = dt_Original.AsEnumerable.Reverse.CopyToDataTable

Regards

2 Likes

I do understand your request that the columns are to reorder (inital First Columns should be the last one …)
like:
grafik

so this can be done by

  • clone the datatable - dtReversed from original DataTable dtData
  • reverse the columns with the setOrdinal method
  • iterate over dtData, take the ItemArray for of each row, reverse it and add it to dtReversed

find some starter help here:
DT_ReverseColumns.xaml (8.5 KB)