0% found this document useful (0 votes)
13 views27 pages

Mod 3

The document outlines four types of UiPath projects: Sequences, Flowcharts, User Events, and State Machines, each serving different automation purposes. It details the functionalities and use cases of Flowcharts, control flow activities such as Assign, Delay, Break, While, Do While, For Each, If, and Switch activities, along with step-by-step examples for practical implementation. The document emphasizes the importance of understanding when to use Sequences versus Flowcharts in automation workflows.

Uploaded by

s s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views27 pages

Mod 3

The document outlines four types of UiPath projects: Sequences, Flowcharts, User Events, and State Machines, each serving different automation purposes. It details the functionalities and use cases of Flowcharts, control flow activities such as Assign, Delay, Break, While, Do While, For Each, If, and Switch activities, along with step-by-step examples for practical implementation. The document emphasizes the importance of understanding when to use Sequences versus Flowcharts in automation workflows.

Uploaded by

s s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

MOD 3

1. UiPath provides four types of projects:

1. Sequences
2. Flowcharts
3. User Events
4. State Machines

1. Sequences

 Purpose: Ideal for simple, linear workflows.


 Use Case: Best suited for straightforward processes with a defined start and end, such as
reading an email, extracting attachments, or performing calculations.
 Key Features:
o Easy to implement and understand.
o Focused on step-by-step execution.

2. Flowcharts

 Purpose: Designed for workflows requiring conditional logic or branching.


 Use Case: Useful for processes involving multiple decision points, like invoice approval
workflows or customer onboarding processes.
 Key Features:
o Visual representation of the process flow.
o Supports complex transitions between activities.

3. User Events

 Purpose: Specialized for front office automation.


 Use Case: Ideal for processes triggered by user interactions, such as keypresses, mouse
clicks, or application state changes.
 Key Features:
o Event-driven architecture.
o Efficient for building reactive automations.

4. State Machines

 Purpose: Suitable for handling complex, non-linear business processes.


 Use Case: Useful for scenarios with multiple states and transitions, such as customer
service ticketing systems or multi-step approval processes.
 Key Features:
o Manages workflows with dynamic states.
o Highly flexible and powerful for complex logic.
2. What Flowcharts are and when to use them
A Flowchart is generally used for complex business processes. It provides decision-making facilities and
can be used for both small and large projects. Here, we can add activities in different ways:

A Flowchart provides multiple branching logical operators to make decisions. A Flowchart is able to run
in reverse. Also, it can be used inside Sequences. A Flowchart facilitates reusability for distinct projects.
Once we create it to use in a project, it can be used for a different but similar project.

A Flowchart's branches are set to true/false by default. However, its names can be manually changed
from the Properties panel. For example, enter two numbers and check whether their sum is less than
20.

Perform the following steps:

1. First, add a Flowchart from the Activities panel into the Designer panel.
2. Add a Sequence activity within the Flowchart.
3. Take two Input dialog activities (for entering the numbers to be added) inside the Sequence
activity.
4. Create the variables x and y to save the values.
5. Next, add a Message box activity to perform a mathematical operation. In our case, the sum of
the two numbers is less than 20:

x + y < 20

6. Now, add a Flow Decision activity to check the mathematical operation.


7. If true, the Flow Decision will flow toward the true branch. Otherwise, it will flow towards the
false branch.
3. Different types of control flow activities.
1. The Assign activity
2. The Delay activity
3. The Break activity
4. The While activity
5. The Do While activity
6. The For each activity
7. The If activity
8. The Switch activity

1. The Assign activity


The Assign activity is used to designate a value to the variable. The Assign activity can be used
for different purposes, such as incrementing the value of a variable in a loop, or using the results
of a sum, difference, multiplication, or division of variables and assigning it to another variable.
2. The Delay activity
The Delay activity, as the name suggests, is used to delay or slow down an automation by
pausing it for a defined period of time. The workflow continues after the specified period of
time. It is in the hh:mm:ss format. This activity plays a significant role when we need a waiting
period during automation, perhaps say, a waiting period required for a particular application to
open.

Example
To better understand how the Delay activity works, let us see an example of an automation that
writes two messages to the Output panel with a delay of 50 seconds.

Perform the following steps:

1. First, create a new Flowchart.


2. Add a Write line activity from the Activities panel and connect it to the Start node.
3. Select the Write line activity. Now, type the following text into the Text box:
"Hey, what is your name?".
4. Next, add a Delay activity and connect it to the Write line activity.
5. Select the Delay activity and go to the Properties panel. In the Duration field, set 00:00:50. This
is a 50-second delay between the two logged messages.
6. Take another Write line activity and connect it to the Delay activity. In the Text field, write
"My name is Andrew Ng.":
7. After clicking on the Run button, the Output panel shows the message that delays it by 50
seconds:
3. The Break activity
The Break activity is used to break/stop the loop at a particular point, and then continue to the
next activity according to the requirement. It cannot be used for any other activity apart from the
For each activity. It is useful when we want to break the loop to continue to the next activity in
the For each activity.

Example

In this example, we will use the Break activity to execute only one iteration.

Perform the following steps:

1. Add a Sequence activity to the Designer panel.


2. Next, add a For each activity inside the Sequence (as mentioned in the preceding section,
to use the Break activity, we need the For each activity):
3. Create two variables; an integer variable named item, and an array integer variable named
x. Then, set them to the text field.
4. Now, assign a default value to the integer variable x.
5. Add a Break activity inside the body of the loop.
6. Under the For Each activity, add a Write line activity.
7. In the Write line activity, type item.ToString in the text field.
8. When we click the Run button, it will display one element, as shown in the following
screenshot. This is due to the Break activity, which has stopped execution after the first
iteration

4. The While activity


The While activity is used in automation to execute a statement or process based on a certain
condition. If found true, the loop is executed; that is, the process is executed repeatedly. The
project only exits from the loop when the condition does not hold true. This activity is useful
while iterating through an array of elements.

Example
In the following example, we will see how an integer variable will increase from 5 to 50 in
increments of 5.

Perform the following steps:

1. On a Blank project, add a Sequence activity.


2. Now, create an integer type variable x. Set its default value to 5.
3. Next, add a While activity to the Sequence.
4. In the condition field, set x<50.
5. Add an Assign activity to the body section of the While loop.
6. Now, go to the Properties panel of the Assign activity and type in the text field integer variable
for value field integer x+5.
7. Drag and drop a Write line activity and specify the variable name x and apply ToString method
on this variable:
8. Now, click the Run button. The output will display in the Output panel, as shown in the following
screenshot:

5. The Do while activity


The Do while activity is used in automation when it is required to execute a statement based on
the fulfillment of a certain condition. How it differs from the While activity is that it executes a
statement, then checks whether the condition is fulfilled. If the condition is not fulfilled, it exits
the loop.

Example

Let us take an example to understand how the Do while activity works in automation.
Take an integer variable. Starting with this variable, we shall generate all multiples of 2,
less than 20.

Perform the following steps:

1. Add a Sequence to the Designer panel.


2. Add a Do while activity from the Activities panel.
3. In the body section of the Do while activity, add an Assign activity.
4. Now, select the Assign activity. Go to the Properties panel and create an integer variable
y. Set its default value to 2.
5. Set y+2 in the value section of the Assign activity to increment the result each time by 2
until the loop is executed.
6. Add a Write line activity inside the Assign activity.
7. In the text field of the Write line activity, type y.
8. In the condition section, set the condition y<20. The loop will continue until the condition
holds true:
9. On clicking the Run button, the output displayed will be as follows:

6. The For each activity


The For each activity works by iterating each element from the collection of items or list of
elements, one at a time. In the process, it will execute all the actions that are available inside the
body. Thus, it iterates through the data and processes each piece of information separately.

Example
In the following example, we shall use the For each activity to go through a collection of even
numbers and display each element one at a time.
Perform the following steps:

1. Start with a Blank project in UiPath.


2. Add a Sequence activity to the Designer panel.
3. Next, add a For each activity within the Sequence and create an integer type array variable, x.
4. In the default value of the variable, put in ({2,4,6,8,10,12,14,16,18,20}).
5. Add a Write line activity to the Designer Panel (this activity is used to display the results).
6. In the Text field of the Write line activity, type item.ToString to display the output:

7. Now, run the program. You will see that each number of the array is displayed one by one
because of the use of the For each activity:

7. The If activity

The If activity consists of a statement with two conditions: true or false. If the statement is true, then
the first condition is executed; if not, the second condition is executed. This is useful when we have to
take decisions on the basis of statements.

To better understand how the If activity works, let us see an example that checks whether the sum of
any two numbers is less than 6.

Perform the following steps:


1. Add a Flowchart from the Activities panel.
2. Add two Input dialog activities. Create two integer variables, x and y.
3. In the Properties panel, change the label name and title name of both the Input dialog activities.
4. Now, specify these name of these two variables in the Result property of both the Input dialog
activities.
5. Now add the If activity to the Designer panel:
6. In the condition part, x+y<6, check whether it is true or false. Add two Write line activities and
type "True" in one and "False" in the other:
7. Click the Run button to check the output. If the condition holds true then it will show the true
value; otherwise, it will show the false value, as shown in the second screenshot (in our case, we
put in the values of x and y as 9 and 4, respectively, thus getting a sum of 13, which is not less
than 6; hence, the output shows it as false value):

8. The Switch activity


The Switch activity can be used to make a choice. When we have various options available and
want to execute one option, we frequently use the Switch activity.

By default, the Switch activity takes an integer argument. If we want to take a desired argument,
then we can change it from the Properties panel, from the TypeArgument list. The Switch
activity is very useful in the categorization of data according to one's own choice.

Example
Let's see an example where we have to check whether a given number is odd or even.

We know that all odd numbers, when divided by 2, leave a remainder of 1. On the other hand,
even numbers, on being divided by 2, leave a remainder of 0. Hence, we will have two cases
getting a remainder of 1 or 0.

Perform the following steps:

1. Add a Sequence activity.


2. Add an Input dialog activity inside the Sequence.
3. Now, create an integer type variable k.
4. Specify the newly created variable's name in the Result property inside the Properties panel.
5. Add the Switch activity under the Input dialog activity.
6. In the Expression field, set k mod 2 to check whether the number is divisible by 2 or not.
7. Add a Write line activity to the Default section and type the k.ToString +" is an even number"
in the text field.
8. Now, create Case 1, add the one other Write line activity to it, and type k.ToString +" is an odd
number" in the text field:

4. Step-by-step example using Sequence and


Flowchart
A Sequence and a Flowchart are similar concepts. They are both used to contain logical steps or
actions. One should know when to use each of them. Where they differ from each other is that a
Sequence is generally used to contain multiple steps to perform an action. A Flowchart, on the
other hand, is suitable for a particular task. When we have lots of steps of a similar kind, we
contain them in a Sequence. There may be different Sequences doing their jobs. We can easily
put similar Sequences into a workflow; each workflow represents a task. It is very easy to test a
separate workflow alone. Let us try to understand them better with an example.

How to use a Sequence

There may be different Sequences doing their jobs. We can easily put similar Sequences into a workflow;
each workflow represents a task. It is very easy to test a separate workflow alone. Let us try to
understand them better with an example.

Perform the following steps:

1. Drag and drop a Flowchart onto the Designer panel. Drag and drop a Sequence activity. Connect
the Sequence activity with the Start node.
2. Double click on the Sequence activity. Drag and drop an Input dialog activity and a Message box
activity. Specify a message in the label property of the Input dialog activity.
3. Create a variable of type String. Give it a name. Also, specify this newly created variable's name
in the content property of the Message box activity:

Let us take an example to see how to use Sequences in the Flowchart.

We are not going to implement the actual code for sending the email. It will be covered later in detail.
The aim of this session is to clearly understand where and how we use workflows and Sequences.

Perform the following steps:

1. Drag and drop two Flowchart activities on the main Flowchart. Rename them as Send
Mail and Message.

We have two different workflows. The Send Mail workflow will send the mail to an email
address. The Message workflow has the message body of that email and will ask the user for a
name, message, sender, and receiver.

2. We have to implement the desired steps in both workflows.

For that, we are using a Sequence inside the Flowchart. Double click on the Flowchart. Drag and
drop a Sequence activity inside both Flowcharts. Connect the Sequence to the Start node by
right-clicking on the Sequence and selecting the Set as Start node option.

3. Double click on the Sequence in the Message Flowchart. Drag and drop four Input
dialog activities for the name, message, sender, and receiver (in this Sequence, we are not
going to set any property of the Message box since the purpose of this lesson is to clearly
understand where and how we use workflows and Sequences):

4. Double click on the Send Mail Flowchart. Double click on the Sequence. You can drag
and drop the email activities here. (We are not going to drag any mail activity although
you are free to do so. There is another chapter for that).
5. That's it. Now, go to the main Flowchart. Connect the Message Flowchart to
the Start node. Also, connect the Send Mail activity to the Message Flowchart:

6. Run the program and visualize it.

5. Step-by-step example using Sequence and Control flow


In this session, we are going to discuss Control flow with an example. We will see how to use
Control flow in a Sequence. There are the various Control flow activities, as mentioned before.

Consider an array of names. Say we have to find out how many of them start with the letter a.
We will then create an automation where the number of names starting with a is counted and the
result is displayed.

Perform the following steps:


1. Drag and drop a Flowchart activity from the Activities panel.
2. Drag and drop a Sequence activity inside the Flowchart. Connect the Sequence to the Start node
by right-clicking on the Sequence activity and selecting the Set as Start node option.
3. Double click on the Sequence activity. Create a variable. Give it a name (in our case, we will
create an array of type string and name the variable as names). Set the variable type to Array
of [T]. When asked for the type of array, select String.

Also, initialize the array in the Default section of the variable by giving it a default values. For
example, {"John", "Sam", "Andrew", "Anita"}.

4. Create a variable of type integer Count for storing the result. Set the variable type to Int32:

5. Drag and drop a For each activity inside the Sequence. Also, specify the array name in the
expression box of the For each activity. The For each activity is used to iterate over the array. It
will pick up one name from the array each time until it reaches the end:

6. Drag and drop the If activity from the Activities panel and place it inside the For
each activity at the location where Drop activity here is mentioned. Specify the condition
in the expression box of the If activity. The If activity is used to check for a particular
condition/expression. If that expression is satisfied, the Then block will be executed.
Otherwise, the Else block will be executed.

We have specified the expression as item.ToString.StartsWith('a'). This expression


specifies the name present in the item variable starts with the letter 'a'. The For each activity
iterates over the array, picks up one name at a time, and stores it as a variable, item:

7. Now, we are going to use the Count variable and increment it each time a name from an array
starts with the letter a. For this, we have to use the A+B Assign activity. Drag and drop the A+B
Assign activity inside the If activity. Set the To property to Count (variable name) and
the Value property to Count+1 (to increment its value) of the A+B Assign activity:

8. Just drag and drop a Message box activity inside the Sequence activity. Specify the count
variable in the expression box of the Message box activity. But remember, the variable
that we have created is of type Int32, so, it cannot be used with the Message box activity
without converting it to a string. To convert it to a string, we have
the '.toString' method available in UiPath Studio. Just apply it to the variable and
select '.toString':
Hit the Run button or press F5 and see the result.

6. What is a Variable?

 A variable is a name assigned to a memory location for storing data.


 Variables should have meaningful names to improve code readability and debugging.

Example:

Instead of temp, use userName for storing a user’s name.

Data Types in UiPath

Different types of data require appropriate variable types to avoid errors.

Type Content

Integer Whole numbers

String Text of any kind ("Hello World")

Boolean Logical values (True or False)

Generic Can store any type of data

Creating Variables in UiPath

1. Go to the Variables Panel.


2. Assign a meaningful name and select a data type.
3. Set the Default Value if needed.

Example:

Variable Name: greetingMessage


Default Value: "Hello, World!"

Scope of Variables

 The scope defines where the variable is accessible.


 A variable’s scope should be limited to the smallest possible region to:
o Prevent accidental modifications.
o Improve code security and readability.
Best Practice:

Avoid setting the scope to the entire workflow unless absolutely necessary.

Example: Using a Variable

Steps:

1. Declare a Variable:
o Name: greetingMessage
o Type: String
o Default Value: "Hello, World!"

2. Add a Message Box:


o Drag a Message Box activity into the workflow.

3. Link the Variable:


o Double-click the Message Box.
o Set the text to greetingMessage.

4. Run the Workflow:


o Click the Run button.

The Message Box will display the text "Hello, World!".

7. Collections in UiPath

Collections allow you to store multiple data points of the same or different types, depending on
the collection type. They are essential for handling and managing multiple pieces of data
efficiently.

Types of Collections

1. Scalar Variables: Store a single data point (e.g., Integer, Double, String).
2. Collections: Store multiple data points of the same or compatible types (e.g., Array, List,
Dictionary).
3. Tables: Represent data in a structured, tabular format (e.g., DataTable).
Understanding Collections

 Array: A fixed-size collection that holds multiple elements of the same data type.
 List: A dynamic collection that can grow or shrink as needed.
 Dictionary: A key-value pair collection for fast lookups.

Working with Arrays in UiPath

Example: Iterating Through an Array

Objective: Initialize an array of integers, iterate through its elements, and display them using a
Message Box.

Steps:

1. Create a Flowchart:
o Drag and drop a Flowchart activity into the main Designer panel.

2. Add a Sequence:
o Drag and drop a Sequence activity inside the Flowchart.
o Set the Sequence as the Start Node.

3. Create an Array Variable:


o In the Variables Panel, create a variable:
 Name: arr
 Type: Array of [Int32]
 Default Value: {1, 2, 3, 4, 5}

4. Add a For Each Activity:


o Drag and drop a For Each activity into the Sequence.
o Set the Type Argument to Int32.
o Specify arr in the Values field.

5. Display Each Element:


o Drag a Message Box activity inside the For Each loop.
o Use the item.ToString expression to convert each element to a string and display it.

Key Points:

 For Each Activity: Automatically generates an item variable representing the current element in
the loop.
 ToString Method: Converts non-string types to a string, required for Message Box input.

Code Example in UiPath:


plaintext
CopyEdit
arr = {1, 2, 3, 4, 5}
For Each (item in arr)
Message Box: item.ToString

Output

When you run the workflow:

1. Each number in the array (1, 2, 3, 4, 5) is displayed sequentially in separate Message Boxes.

Advantage of Collections

1. Efficient Data Management: Handle multiple values without creating multiple variables.
2. Iterative Operations: Easily perform actions on each item in a collection.
3. Dynamic Behavior: Lists and dictionaries adapt to changing data sizes and relationships

8. Arguments in UiPath

Arguments in UiPath are used to pass data between workflows, enabling interaction and data
exchange in modular automation projects. Unlike variables, which are limited to a specific scope,
arguments have a broader role, as they facilitate communication across workflows.

Purpose of Arguments

1. Workflow Modularity: Break down large projects into smaller, manageable workflows.
2. Data Exchange: Transfer data between workflows efficiently.
3. Improved Testing: Test individual workflows in isolation with defined inputs and outputs.
4. Reusability: Reuse workflows across different projects by defining flexible arguments.

Types of Argument Directions

Direction Purpose Usage

In Receive data from the caller workflow. Pass input values into a workflow.

Out Send data to the caller workflow. Pass output values from a workflow.

In/Out Both input and output. Exchange data in both directions.

Property Not currently in use. For defining properties within workflows.


Direction Purpose Usage

Creating and Using Arguments

Steps to Create an Argument:

1. Open the Arguments Panel:


o Go to the main Designer Panel.
o Click on the Arguments tab.

2. Define the Argument:


o Provide a Name (e.g., inputValue or outputResult).
o Select the Argument Type (e.g., String, Int32).
o Set the Direction (In, Out, In/Out, or Property).

3. Use the Argument in Activities:


o Reference the argument within the workflow just like a variable.

4. Link Arguments to Workflows:


o When invoking a workflow using the Invoke Workflow File activity, map the arguments
to appropriate values or variables.

Example: Passing Data Between Workflows

Scenario:

 Workflow A sends a value to Workflow B.


 Workflow B performs an operation and sends the result back to Workflow A.

Workflow A:

1. Define an Out Argument (outputValue) to send data.


2. Use an Invoke Workflow File activity to call Workflow B.
3. Map Workflow B’s In argument to Workflow A’s variable.

Workflow B:

1. Define an In Argument (inputValue) to receive data.


2. Define an Out Argument (resultValue) to send the result.
3. Perform the desired operation and assign the result to resultValue.

Execution Flow:

1. Workflow A passes a value (inputValue) to Workflow B.


2. Workflow B processes the value and returns the result via resultValue.
3. Workflow A retrieves and uses the result.

9. Data Table Usage in UiPath

A Data Table in UiPath is a tabular data structure used for storing and manipulating data in rows
and columns, similar to how data is organized in a spreadsheet or database. It is extensively used
in automation workflows for building, manipulating, and processing data dynamically.

Key Features of Data Tables

 Tabular Structure: Stores data in rows and columns.


 Dynamic Creation: Can be built programmatically or through activities.
 Versatile Applications: Used in data scraping, data processing, and storage.

Example 1: Building a Data Table

Steps to Build a Static Data Table

1. Create a New Project:


o Start a new project and give it a meaningful name.

2. Set Up Activities:
o Drag a Flowchart activity onto the Designer Panel.
o Inside the Flowchart, place a Sequence activity and set it as the start node.

3. Add a Build Data Table Activity:


o Drag the Build Data Table activity into the Sequence.
o Click on the Data Table button in the activity to open the editor.

4. Define the Columns:


o Remove the default columns and add new columns:
 Name (String)
 Roll_No (Int32)
 Class (String)

5. Add Rows of Data:


o Input data for each row, such as:

yaml
CopyEdit
Name: Andrew Jose, Roll_No: 1, Class: 3
Name: Jorge Martinez, Roll_No: 2, Class: 3
Name: Stephen Cripps, Roll_No: 3, Class: 2

6. Store the Data Table in a Variable:


o Create a variable (MyDataTable) of type DataTable.
o Assign this variable in the Output property of the Build Data Table activity.

7. Iterate Over the Rows:


o Drag a For Each Row activity into the Sequence.
o Specify MyDataTable in the activity’s DataTable property.
o Drag a Message Box activity into the For Each Row loop.
o Set the text as:

plaintext
CopyEdit
row("Name").ToString + "-" + row("Roll_No").ToString + "-" +
row("Class").ToString

8. Run the Workflow:


o Click Run and observe the output for each row displayed sequentially.

Example 2: Building a Data Table Using Data Scraping

Steps to Create a Dynamic Data Table

1. Set Up Web Automation:


o Drag an Open Browser activity into the Sequence and provide the URL of the webpage
(e.g., Amazon's book listings).

2. Use the Data Scraping Wizard:


o Click the Data Scraping option in the toolbar.
o Select the first UI element to scrape (e.g., book title).
o Select a similar second element to establish a pattern.

3. Define Data Columns:


o Name the extracted column (e.g., BookTitle).
o Add correlated data (e.g., price, rating) by repeating the selection process.
4. Handle Pagination (Optional):
o If the data spans multiple pages, select the Next Page button when prompted.
o Specify the maximum number of rows to scrape (default: 100).

5. Generate the Data Table:


o The Data Scraping wizard will generate a DataTable variable (e.g.,
ExtractedDataTable).

6. Convert the Data Table to Text:


o Drag the Output Data Table activity.
o Set its Input property to ExtractedDataTable.
o Store the output as a string variable (e.g., result).

7. Display the Data:


o Drag a Message Box activity and set its Text property to result.

8. Run the Workflow:


o Execute the workflow to extract and display data from the webpage.

10. Clipboard Management in UiPath

Clipboard management involves managing the clipboard's activities, such as copying text to the
clipboard, retrieving text from it, and using it in automation workflows. UiPath provides
activities like Get From Clipboard and Copy Selected Text to simplify clipboard interactions.

Example: Getting Text from Clipboard

This example demonstrates:

 Writing data into Notepad


 Copying the data to the clipboard
 Extracting and displaying the copied data

Steps to Implement Clipboard Management


1. Drag and Drop a Flowchart Activity

 Open UiPath Studio and drag the Flowchart activity to the Designer panel.

2. Use Desktop Recording

 Click on the Recording button in the toolbar and select Desktop Recording from the dropdown
menu.

3. Automate Notepad Interaction

 Open Notepad:
o Start recording and click on Notepad to open it.
 Type Data:
o Click on the Notepad text area.
o Use the Type Into activity to enter text (e.g., "Hello, UiPath!").
o Check the Empty Field checkbox to clear any existing text in Notepad.

4. Copy Text in Notepad

 Select All:
o Click on the Edit menu.
o Choose the Select All option to highlight the text in Notepad.
 Copy Text:
o Again, click on the Edit menu.
o Select the Copy option to copy the highlighted text to the clipboard.

5. Retrieve Text from the Clipboard

 Insert the Copy Selected Text Activity:


o Drag the Copy Selected Text activity into the generated recording sequence.
 Create a Variable:
o Create a variable (e.g., clipboardText) of type String.
o Assign this variable in the Output property of the Copy Selected Text activity to store
the clipboard content.

6. Display Clipboard Content

 Add a Message Box:


o Drag the Message Box activity into the sequence.
o In the Text property, specify the variable clipboardText to display the retrieved text.
7. Run the Workflow

 Click the Run button to execute the workflow.


 Observe the following:
o Notepad opens, data is written, selected, and copied to the clipboard.
o The text from the clipboard is retrieved and displayed in a message box.

11. File operation with step-by-step example


In this module, we are going to operate on Excel file. The following are the methods that are frequently
used with an Excel file:

1. Read cell
2. Write cell
3. Read range
4. Write range
5. Append range

Read Cell in UiPath

The Read Cell activity in UiPath allows you to extract the value of a specific cell from an Excel
file. Below is a step-by-step guide to demonstrate how to use the Read Cell activity.

Steps to Read a Cell Value

1. Prepare the Excel File

 Ensure you have an Excel file with data. For example:

css
CopyEdit
| A | B | C |
|-------|-------|-------|
| Name | Age | City |
| John | 25 | NY |
| Alice | 30 | LA |

 Place this file in an accessible location.


2. Drag and Drop Activities

 Flowchart:
o Drag and drop a Flowchart activity into the Designer panel.
 Excel Application Scope:
o Drag and drop the Excel Application Scope activity inside the Flowchart.
o Connect it to the Start node.

3. Configure the Excel Application Scope

 Double-click on the Excel Application Scope activity.


 Specify the file path of your Excel file in the WorkbookPath property.

4. Add Read Cell Activity

 Drag and drop the Read Cell activity inside the Excel Application Scope activity.
 Configure the following:
o Range: Specify the cell to read (e.g., B3).
o Output: Create a variable of type String (e.g., Result) to store the value of the cell.
o Assign this variable to the Output property.

5. Add a Message Box

 Drag and drop the Message Box activity inside the Excel Application Scope.
 Configure the Text property to display the value stored in the variable (e.g., Result).

6. Run the Workflow

 Press F5 or click on the Run button.


 Observe the following:
o The value of the specified cell (B3) will be displayed in the message box.

2. Write Cell in UiPath

The Write Cell activity in UiPath allows you to write a specific value into a cell of an Excel file.
Here's a step-by-step guide to using this activity.
Steps to Write a Cell Value

1. Prepare the Excel File

 Create or have an Excel file ready with existing or blank data. For example:

css
CopyEdit
| A | B | C |
|-------|-------|-------|
| Name | Age | City |
| John | 25 | NY |
| Alice | 30 | LA |

2. Add and Configure Activities

 Flowchart:
o Drag and drop a Flowchart activity into the Designer panel.
 Excel Application Scope:
o Drag and drop an Excel Application Scope activity into the Flowchart.
o Connect it to the Start node.
o Specify the file path of the Excel file in the WorkbookPath property.

3. Add Write Cell Activity

 Drag and drop the Write Cell activity inside the Excel Application Scope.
 Configure the following:
o Range: Specify the cell where you want to write (e.g., C3).
o Value: Enter the value to write in the cell (e.g., "Seattle").

4. Execute the Workflow

 Press F5 or click on the Run button.


 The workflow will open the specified Excel file and write the value into the specified cell.

3. Read Range in UiPath

The Read Range activity in UiPath is used to read a specified range of data from an Excel file
into a DataTable. If no range is specified, the entire worksheet is read.

Steps to Use Read Range


1. Prepare the Excel File

 Example:

css
CopyEdit
| A | B | C |
|-------|-------|-------|
| Name | Age | City |
| John | 25 | NY |
| Alice | 30 | LA |
| Mark | 28 | SF |

2. Add and Configure Activities

1. Flowchart:
o Drag and drop a Flowchart activity into the Designer panel.

2. Excel Application Scope:


o Drag and drop an Excel Application Scope activity into the Flowchart.
o Connect it to the Start node.
o Specify the file path of the Excel file in the WorkbookPath property.

3. Read Range:
o Drag and drop the Read Range activity inside the Excel Application Scope.
o Specify the range you want to read:
 Leave Range blank to read the entire sheet.
 Specify a range (e.g., "A1:C3") to read specific cells.
o Create a variable of type DataTable to store the output (e.g., MyDataTable).
o Assign this variable in the Output property.

4. Output Data Table:


o Drag and drop the Output Data Table activity after the Read Range activity.
o Convert the DataTable into a string:
 Set the Input property to the variable storing the DataTable (e.g.,
MyDataTable).
 Create a String variable (e.g., Result) to store the converted output.
 Assign this variable in the Text property.

5. Message Box:
o Drag and drop a Message Box activity.
o Set the Text property to the variable containing the string (e.g., Result).

Execution
1. Press F5 or click the Run button.
2. The workflow will:
o Open the Excel file.
o Read the specified range into a DataTable.
o Convert the DataTable into a string format.
o Display the data in a pop-up window.

4. Write Range in UiPath

The Write Range activity is used to write data into an Excel worksheet from a DataTable. It
outputs the data in a structured format, starting from the specified range.

Steps to Use Write Range

1. Build the DataTable

1. Add Build Data Table Activity:


o Drag and drop a Build Data Table activity from the Activities panel.
o Double-click on it to open the configuration window.

2. Configure Columns:
o Delete default columns by clicking the trash icon.
o Add new columns:
 Click the + icon.
 Specify the column name (e.g., Name, Roll).
 Choose a Data Type (e.g., String, Int32).
o Repeat for each column.

3. Initialize Rows:
o Add rows directly by filling in values for each column in the table preview.

4. Create a Variable:
o Create a DataTable variable (e.g., MyDataTable).
o Assign this variable to the Output property of the Build Data Table activity.

2. Write Data to Excel

1. Excel Application Scope:


o Drag and drop the Excel Application Scope activity into the Designer panel.
o Specify the Excel file path or use the folder icon to select it.
o Connect this activity to the Build Data Table activity.

2. Write Range Activity:


o Drag and drop a Write Range activity inside the Excel Application Scope.
o Configure properties:
 Data Table: Set it to the variable holding your DataTable (e.g., MyDataTable).
 Range: Leave blank to write starting from cell A1 or specify a range (e.g., "B2").
 AddHeaders: Check this option if you want to include column headers.

Execution

1. Press F5 or click the Run button.


2. The workflow will:
o Create a DataTable.
o Open the specified Excel file (or create one if it doesn’t exist).
o Write the DataTable contents to the sheet, starting from the defined range.

5. Append Range in UiPath

The Append Range activity allows you to add new data to an existing Excel file. The data is
appended to the end of the existing data in the worksheet, making it a useful activity when you
need to update an Excel file without overwriting its existing content.

Steps to Use Append Range

1. Read Data from Excel

1. Add Excel Application Scope:


o Drag and drop the Excel Application Scope activity to the Flowchart.
o Specify the path of the existing Excel file from which data will be read.

2. Read Range Activity:


o Inside the Excel Application Scope, add the Read Range activity.
o This activity will read the existing data in the Excel sheet and return it as a DataTable.
o Output: Create a DataTable variable (e.g., MyDataTable) to store the data.
o The Range property can be left empty to read all available data.

2. Append Data to Another Excel File

1. Add Excel Application Scope for Appending:


o Drag and drop another Excel Application Scope activity.
o Specify the path of the target Excel file where data should be appended.

2. Append Range Activity:


o Inside the second Excel Application Scope, add the Append Range activity.
o File Path: Specify the path of the Excel file where you want to append the data.
o DataTable: Select the DataTable variable (e.g., MyDataTable) that holds the data read
from the first file.

Execution

1. Press F5 or click the Run button.


2. The workflow will:
o Read data from the source Excel file using the Read Range activity.
o Open the target Excel file (or create it if it doesn’t exist).
o Append the data at the end of the existing data in the target file.

12. CSV/Excel to DataTable and Vice Versa in UiPath

This section explains how to work with data in Excel files and convert them into DataTable
objects, and also how to write a DataTable into an Excel file. Below are the step-by-step
procedures for each operation:

1. Read Excel to DataTable

In this example, we'll read data from an Excel file and store it in a DataTable.

Steps:

1. Drag a Flowchart Activity:


o From the Activities panel, drag and drop a Flowchart activity onto the main Designer
panel.

2. Add Excel Application Scope:


o Inside the Flowchart, drag and drop the Excel Application Scope activity.
o Specify the path of your Excel file in the Excel Application Scope properties.

3. Read Range Activity:


o Drag the Read Range activity from the Activities panel into the Excel Application Scope.
o The Read Range activity will read the entire Excel sheet (if no range is specified).
o Create a DataTable variable: Create a new DataTable variable to store the output (e.g.,
dtExcelData).
o Assign this DataTable variable to the Output property of the Read Range activity.

4. Convert DataTable to String:


o Drag the Output Data Table activity inside the Excel Application Scope.
o In the DataTable property, select the DataTable variable (dtExcelData).
o In the Text property, create a string variable (e.g., strOutput) to store the result.

5. Display the Data:


o Drag a Message Box activity to show the contents of the DataTable.
o Set the Message Box’s Text property to the string variable (strOutput).

6. Run the Workflow:


o Press F5 to run the workflow.
o A Message Box will pop up, displaying the data read from the Excel file.

2. Write DataTable to Excel

Now, let's create a DataTable dynamically and write it to an Excel file.

Steps:

1. Build a DataTable:
o Drag and drop the Build Data Table activity from the Activities panel.
o Click on the DataTable property to configure the DataTable structure.
o In the Build Data Table configuration window, delete the two default columns and add
your own columns (e.g., "Name" and "Roll").
o Set the Data Type of the columns (e.g., String for "Name" and Int32 for "Roll").

2. Initialize the DataTable:


o Add some sample data to the DataTable. You can do this manually or by using Add Data
Row activities.

3. Excel Application Scope:


o Drag and drop the Excel Application Scope activity to the Designer panel.
o Specify the path of the Excel file where the DataTable will be written.

4. Write Range Activity:


o Inside the Excel Application Scope, drag the Write Range activity.
o Set the DataTable property to the DataTable variable (e.g., dtSampleData).
o Leave the Range property empty to start writing from the first row.
o Make sure the AddHeaders property is set to True if you want to include column
headers.
5. Run the Workflow:
o Press F5 to run the workflow.
o The DataTable will be written to the specified Excel file, starting from the first row.

Example

Initial Excel File (Before Reading)


Name Roll

Alice 101

Bob 102

Excel File After Writing Data (Generated by the Build Data Table Activity)
Name Roll

John 103

Charlie 104

Sample DataTable (Used in the Write Range)


plaintext
CopyEdit
Name | Roll
-------------------
John | 103
Charlie | 104

You might also like