UiPath.Excel.Activities.ExcelInsertDeleteColumns
Adds or removes a specified number of columns at a certain position.
Properties
Common
- DisplayName - The display name of the activity.
Destination
- NoColumns - The number of columns you wish to add or remove. This field supports only integers or
Int32
variables. - Position - The column where the insertion or removal begins. This field supports only integers or
Int32
variables.
Input
- ChangeMode - Selects whether the activity adds or removes columns. Selecting Add will add columns to the document, while selecting Remove will remove them.
- SheetName - The name of the sheet in the workbook where the change must be made. This field supports only strings and String variables.
Misc
- Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
Example of Using the Insert/Delete Columns Activity
The example below explains how to create a new workbook that copies data from a specified .xlsx
file, deletes a range of columns and inserts a new column.
This is how the automation process can be built:
- Open Studio and create a new Process named by default Main.
- Drag a Sequence container in the Workflow Designer and create the following variable:
Variable Name | Variable Type | Default Value |
---|---|---|
| GenericValue |
- Drag an Assign activity inside the sequence container.
- Add the variable
NewFile
in the To field and the expressionDateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH''mm''ss")+".xls"
in the Value field.
- Add the variable
- Place a Copy File activity below the Assign activity.
- In the Properties panel, add the value
"Interest-Rates.xls"
in the Path field and the variableNewFile
in the Destination field.
- In the Properties panel, add the value
- Drag an Excel Application Scope under the Copy File activity.
- Add the variable
NewFile
in the WorkbookPath field. - In the Properties panel, 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.
- Add the variable
- Drag an Excel Delete/Insert Columns activity inside the Do container.
- In the Properties panel, add the value
6
in the NoColumns field. This represents how many columns are deleted. - Add the value
5
in the Position field. This represents the column from which the deleting process begins. - Select the
Remove
option from the ChangeMode drop-down list. - Add the expression
"Short_term_Interest_Rates"
in the SheetName field.
- In the Properties panel, add the value
- Drag another Excel Delete/Insert Columns activity and place it below the first one.
- In the Properties panel, add the value
1
in the NoColumns field. This represents how many columns are inserted. - Add the value
5
in the Position field. This represents the column from which the inserting process begins. - Select the
Add
option from the ChangeMode drop-down list. - Add the expression
"Short_term_Interest_Rates"
in the SheetName field.
- In the Properties panel, add the value
- Add an Excel Write Cell activity under the Delete/Insert Columns activities. This creates a new column with the name
Average
.- In the Properties panel, add the expression
"E4:E4"
in the Range field. - Add the name
"Short_term_Interest_Rates"
in the SheetName field. - Add the expression
"Average"
in the Value field.
- In the Properties panel, add the expression
- Add another Excel Write Cell activity right below the first one. This activity calculates the average interest rates.
- In the Properties panel, add the expression
"E5:E35"
in the Range field. - Add the name
"Short_term_Interest_Rates"
in the SheetName field. - Add the expression
"=AVERAGE(F5:P5)"
in the Value field.
- In the Properties panel, add the expression
- Run the process. The automation process creates a new workbook and manipulates the data from the original one.
Download example
Updated 8 months ago