Table Functions
The example below explains how to maximize the use of tables when creating an automation process. It presents activities such as Filter Table, Sort Table, Get Table Range and Read Range. You can find these activities in the UiPath.Excel.Activities package.
This is how the automation process can be built:
-
Open Studio and create a new Process.
-
Drag a Sequence to the Workflow Designer
- Create the following variables:
Variable name Variable type Default value PasswordGenericValue N/A FilteredEmployeesDataTable N/A noteAdd the file
Employees.xlsxinto the project folder. All data is retrieved from this file. -
Drag a new Sequence container inside the previously created one and name it Retrieve Excel Password.
-
Add an Assign activity inside the Retrieve Excel Password sequence.
- In the Properties panel, add
Passwordin the To field and"1o2Pqdf6A"in the Value field. You need to do this because theEmployees.xlsxfile is password protected.
- In the Properties panel, add
-
Drag an Excel Application Scope activity below the Retrieve Excel Password sequence.
- WorkbookPath field must be populated with
"Employees.xlsx". - In the Properties panel, select the check boxes for ReadOnly and Visible options. This makes the
"Employees.xlsx"file visible to anyone in a Read only mode.
- WorkbookPath field must be populated with
-
Add a new Sequence container in the body of the Excel Application Scope.
-
Drag a Filter Table activity inside the newly created Sequence.
- In the Properties panel add
Fieldvalue in the ColumnName field,{"Police", "Fire"}in the FilterOptions field ,"DataExtract"in the SheetName field and"Employees"in the TableName field.
- In the Properties panel add
-
Add a Sort Table activity under the Filter Table activity.
- In the Properties panel, add
"Income"in the ColumnName field,"DataExtract"in the SheetName field and"Employees"in the TableName field.
- In the Properties panel, add
-
Drag a Get Table Range activity below the Sort Table activity.
- Go to the Properties panel and add the following information: add
"DataExtract"in the SheetName field, add"Employees"in the TableName field andAllEmployeesin the Range field.
- Go to the Properties panel and add the following information: add
-
Add a Write Line activity underneath the Get Table Range activity.
- Add this syntax
"Employees list: " + AllEmployeesin the Text field.
- Add this syntax
-
Drag an Excel Read Range activity below the Write Line activity.
- In the Properties panel, add
AllEmployeesin the Range field,"DataExtract"in the SheetName field andFilteredEmployeesin the DataTable field. - The check boxes for AddHeaders and UseFilter must be selected because the first row contains the table headers and we only need to retrieve the filtered data.
- In the Properties panel, add
-
Drag a For Each Row activity and place it below the Excel Application Scope activity.
- In the Properties panel, add the variable
FilteredEmployeesin the DataTable field.
- In the Properties panel, add the variable
-
Add a new Write Line activity in the body of the For Each Row activity.
- In the Text field, add the following syntax
String.Format("{0,-15} {1, -30} {2, 10}", row("Income"), row("Name"), row("Work")).