How To Read Values From DataTable(Excel) – In UiPath

During automation, we deal with a lot of data in the form of Text files, Excel sheets, and many other such sources.

For now, let us consider Excel’s data.

Let’s see how to read the values from DataTable!!!

Example (Article +Video)

Implementation using UiPath :

Let us implement a workflow to read values from DataTable(Excel) and display them on the screen.

“C:\\Sample_Data.xlsx”
Read values from DataTable 11.PNG

Different ways in which we can fetch values from DataTable:

1. Using UiPath activity
2. Using Column Name along with DataRow Object
3. Using Column Index along with DataRow Object

Step 1:
Drag “Excel Application Scope” activity into the designer panel and supply the sample Excel file’s path to it.

Ex: “D:\Sample_Data.xlsx”

Read values from DataTable 1.PNG

Step 2:
Drag “Read Range” activity into the designer panel and supply the “SheetName” to it and create a variable to store the output DataTable.

Read values from DataTable 2Read values from DataTable 3

Step 3:
Drag “For Each Row” activity into the designer panel, So that we can Loop(Iterate) through the DataTable obtained from the above step.

Read values from DataTable 4.PNG

Step 4:

1. Using UiPath activity

Step 4.1:

Drag “Get Row Item” activity and supply the desired fields to it.

Ex:
The DataRow Object
The Column Name

Read values from DataTable 5Read values from DataTable 6

Step 4.2:

Drag “Message Box” activity to display the above-fetched value.

Read values from DataTable 7

Step 4.3:

Similarly, try doing it for another column available i.e. “ID”

Read values from DataTable 8

Step 5:

Using Column Name along with DataRow Object

Step 5.1:

Drag “Message Box” activity into the designer panel and pass the below-mentioned code.
Syntax : row(“ColumnName”)

Example:
row(“Name”)
row(“ID”)

Read values from DataTable 9.PNG

Step 6:

Using Column Name along with DataRow Object

Step 6.1:

Drag “Message Box” activity into the designer panel and pass the below-mentioned code.
Syntax : row(“ColumnIndex”)

Example:
row(0) , Because the DataTable index starts from zero
row(1)

Read values from DataTable 10.PNG

Step 7:
Finally, execute the workflow and observe the output carefully 🙂

Click here to download the Source Code…

Hope it has helped you

Leave a Reply

%d bloggers like this: