UiPath- To sort a column in an excel file

ray sha
4 min readSep 25, 2020

--

INPUT

Input: An excel file

Name: input.xlsx

Adding a screenshot of the excel file.

OUTPUT

Output: An excel file

Name: output.xlsx

Adding a screenshot of the excel file.

Sorted in ascending Order
Sorted in Descending Order

FLOW

To achieve the desired output, please follow the below steps:

1. Open UiPath Studio. Select “Process.”

2. Create a new process by entering a valid name and change the description to something meaningful. Location must be the path where you want to save the process.

3. From the activities panel, select a sequence or a flowchart. I’m starting with a sequence. Rename the sequence to something meaning. Add annotations.

4. Select the Excel Application scope from the activities panel in the sequence. Give the path to the Excel file.

5. In the Excel Application scope, use a Read range activity. Be careful here, there are two Read range activities, One for Excel and the other for workbook. If you use the Workbook’s Read Range, then do not use the excel application scope. Since we are using Excel Application Scope, use Read Range for Excel.

Path must be given in between “ ”.

6. The properties of Read Range are shown below. Output of Read Range must be of type Data Table. Create a new variable from the Variable panel or use ctrl+K to create a variable.

input_Datatable is the variable I’ve used in the Output tab. It holds all the contents of excel.

Datatable: input_Datatable

AddHeaders: True

7. In the variable panel, extend the scope of the data table to the entire sequence

8. Use a “Sort Data Table” activity. The contents of this activity are:

Input:

Datatable: input_Datatable

Output:

Datatable: output_Datatable

Sorting Column:

Order: Ascending; if you want the column to be sorted in ascending order.

Order: Descending; if you want the column to be sorted in descending order.

There are three options which you can use to indicate the column which must be sorted.

· Column

· Index

· Name

I’ve used Name.

Name: “Name”

Where “Name” is the column name in my input excel.

9. After this use an “Excel application scope” with a write range (for Excel) activity.

Enter a valid Path. The contents of write range are

Sheet Name: Sheet1

Starting Cell: “A1”

Datatable: output_Datatable

Add headers: True

10. In the variable panel, extend the scope of output_Datatable

I really hope this solves your doubt. Feel free to reach out to me for any further queries.

Always remember to be kind.

All the best and Happy learning!

--

--

ray sha
ray sha

Written by ray sha

An effort towards making myself happy!

No responses yet