Excel Application Scope In UiPath (RPA)

In this article, we will explore the Excel activities in UiPath. Here, we are taking the same Excel which we used in my previous RPA article. To learn how to create a project and sequence file into that, go through this article.
 

Excel Application Scope

 
As the name suggests, this activity helps us to perform different operations on an Excel file.
 
Note
To use this activity, we need Microsoft Excel to be installed on our machine. If it is not installed, you will get this kind of error.
 
Excel Application Scope in UiPath (RPA)
 
There are a number of properties for this activity.
 
Excel Application Scope in UiPath (RPA)
 
Below are the frequently used properties.
 
DisplayName
 
The display name of the activity; we always should give a meaningful name to the activity.
 
AutoSave
 
By default selected; It automatically saves the workbook whenever any change is made to it. If disabled, then your changes will not be saved at the end of the Excel Application Scope.
 
Create New File
 
By default selected; If you give a file path and that is not found, then it will create the same and perform operations on it. If the checkbox is not selected, then an exception is thrown if the workbook cannot be found at the specified path.
 
Visible
 
By default selected. All operations on Excel will be visible to you during execution. If not selected, then it will happen in the background.
 
Workbook
 
The complete data from the Excel sheet will be stored in a WorkbookApplication variable. We can use this in another Excel Application Scope activity. Only WorkbookApplication DataType variables are supported.
 
ExistingWorkbook
 
As mentioned in the above property, we can use WorkbookApplication variable into another Excel Application Scope activity so we can achieve that using this property.
 
Get Workbook Sheet Activity
 
Excel Application Scope in UiPath (RPA)
 
Has a property called Index where we can give the index number of a sheet which we want to read, indexing starts from 0.
 
If you pass an index that is not present, then it will give you the following error.
 
Excel Application Scope in UiPath (RPA)
 
Get Workbook Sheets Activity
 
 Excel Application Scope in UiPath (RPA)
 
This activity returns a list of all the sheet names in an Excel workbook (List of the strings with an index order). The output variable should be of IEnumerable type.
 
Copy SheetActivity
 
It is used to copy the complete sheet data from one to another sheet.
 
Excel Application Scope in UiPath (RPA)
 
Properties
  • DestinationFilePath
  • DestinationSheetName
  • SheetName
If DestinationSheetName is already present in that Excel workbook, then it gives an error, so make sure the sheet name is unique.
 
Excel Application Scope in UiPath (RPA)
 
Read Range Activity
 
To read sheet data we use this activity. Input is the sheet name and output is a DataTable.
 
Excel Application Scope in UiPath (RPA)
 
Append Range Activity
 
Excel Application Scope in UiPath (RPA)
 
It appends the data from DataTable to a sheet. If the sheet is not present, then a new one is created automatically with sheet name which is passed to this activity.
 
Read Cell
 
Excel Application Scope in UiPath (RPA)
 
It reads the value of an Excel cell and stores it in an output variable. Cell value should be only String. When you create the output variable in property using “ctrl+K” key, then by default, the data type of that variable will be “Generic”.
 
Read Column
 
It returns an IEnumerable <object> list in defined variable. Starting Cell value is must. This activity fetches all cell values from the starting cell into one column.
 
Excel Application Scope in UiPath (RPA)
 
Read Row
 
It does almost the same as “Read Column”. The only difference is that it returns the value from row instead of column.
 
Excel Application Scope in UiPath (RPA)
 
Write Cell
 
It writes a value into a cell of the given sheet name. If the sheet does not exist, a new one is created with the SheetName value. Value is overwritten if it exists.
 
Excel Application Scope in UiPath (RPA)
 
We can pass the cell range instead of a single cell just like below and after execution, the “Hello UiPath” value will be written in a specified range.
 
Excel Application Scope in UiPath (RPA)
 
Here is the output of the above activity
 
Excel Application Scope in UiPath (RPA)
 
Write Range
 
This might be confusing for you as in the above activity, “Write Cell”, we have also provided a cell range. Then why this activity is needed or what is the difference between these two activities?
 
To this activity, we can pass DataTable as input, whose data will be written in the Excel file from the starting cell. In this case, that is “G1”. So, the difference between these two is that “Write Cell” can write the same value into multiple cells and “Write Range” can write different kinds of data into different cells.
 
Excel Application Scope in UiPath (RPA)

Summary

 
We have seen how we can use different Excel activities to read/write/copy data from the workbook. All these activities are present under “UiPath.Excel.Activities” package. If you don’t see any of these activities, then you have to download this package from “Manage Packages”.


Similar Articles