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
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.
Get Workbook Sheets Activity
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.
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.
Read Range Activity
To read sheet data we use this activity. Input is the sheet name and output is a DataTable.
Append Range Activity
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
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.
Read Row
It does almost the same as “Read Column”. The only difference is that it returns the value from row instead of column.
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.
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.
Here is the output of the above activity
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.
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”.