Manage Pivot Tables
The example below explains how to create and refresh a pivot table. It presents activities such as Create Pivot Table, Refresh Pivot Table. 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 named by default Main.
note
Add the example.xlsx file used for retrieving data in the main folder of the project. The automation process uses this file to extract and manipulate the raw data.
- Drag a Sequence container in the Workflow Designer.
- Place an Excel Application Scope activity inside the body of the Sequence.
- In the Properties panel add the path
"example.xlsx"in the WorkbookPath field. - Select the check boxes for the AutoSave, CreateNewFile and Visible options. The robot is now allowed to create a new Excel workbook, to automatically save all the changes made to it and to open the Excel file in the foreground while performing actions on it.
- In the Properties panel add the path
- Select the Do sequence container inside the Excel Application Scope activity.
- Create a variable named
rangeResultand of type String.
- Create a variable named
- Drag a Create Pivot Table activity inside the Do sequence.
- In the Properties panel, add the value
L9in the Range field, the namepivotin the TableName field, the name"SalesOrders"in the SheetName field, and the name"table"in the SourceTableName field.
- In the Properties panel, add the value
- Place a Message Box activity below the Create Pivot Table activity.
- In the Properties panel add the value
Okin the Buttons field and add"Check the pivot table in the Excel file."in the Text field. Select the check box for the TopMost option for always having the message box displayed to the foreground.
- In the Properties panel add the value
- Drag a Delete Range activity under the Message Box activity.
- In the Properties panel add
"A6:G16"in the Range field, add the value"SalesOrders"in the SheetName field and the valueShiftUpin the ShiftOption field. - Select the ShiftCells check box for shifting the cells according to the ShiftOption.
- In the Properties panel add
- Place a Refresh Pivot Table activity under the Delete Range activity.
- In the SheetName field add the name of the sheet,
SalesOrders. - In the TableName field add the name of the table,
pivot.
- In the SheetName field add the name of the sheet,
- Run the example. The automation process uses the data in the
example.xlsxfile to create a pivot table and refreshes the initial table by deleting a range of cells.