How To Transpose DataTable – In UiPath

luke-chesser-JKUTrJ4vK00-unsplash.jpg

Few times while working with DataTables, we might want to convert rows to column and vice versa.

let’s see how to do that…!!!

Example

Implementation using UiPath :

Let us implement a workflow to convert rows to columns in DataTable.

(If you find the logic a little difficult to understand, no worries please leave a comment and we will get back to you soon)

Sample File:
UiPath DataTable Transpose 0.PNG

Step 1:
Drag “Excel application scope” and “Read Range” activities into the designer panel to read the input excel

UiPath DataTable Transpose 1.PNG

Step 2:
Drag “While“, “Add Data Column” and “Assign” activities into the designer panel to create dummy columns
(Because here we are transposing the headers too)

UiPath DataTable Transpose 2.PNG

Step 3:
Drag “For Each Row“, “While“, “Add Data Row” and “Assign” activities into the designer panel and write the logic to convert rows to columns.

UiPath DataTable Transpose 3.PNG

Step 4:
Finally, execute the workflow to see the results πŸ™‚

UiPath DataTable Transpose 4

Click hereΒ to download the Source Code…

Hope it has helped you…

6 thoughts on “How To Transpose DataTable – In UiPath

  1. rohit

    what is in while loop can elaborate please

    1. Hi Rohit
      Sure!!!

      Pink me on LinkedIn
      http://linkedin.com/in/sharath-raju

      We can discuss over there πŸ™‚

  2. Hi Sharath Raju,

    Can you please explain the transpose project in detail, i.e. what is the neccessity of each activity inside the for each loop. it would be helpful for us to catch the stuff easily.

    Best Regards,
    Naveen Kumar S

    1. Sure Naveen, will try to do it πŸ™‚

  3. Rohit Lanjewar

    Hi Sharath!! I have your code in my project But I am getting error as RemoteException wrapping System.ArgumentException: Input array is longer than the number of columns in this table.

    1. No worries Rohit, once check for the number of columns count and the array items count?

Leave a Reply

%d bloggers like this: