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”
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”
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.
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.
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
Step 4.2:
Drag “Message Box” activity to display the above-fetched value.
Step 4.3:
Similarly, try doing it for another column available i.e. “ID”
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”)
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)
Step 7:
Finally, execute the workflow and observe the output carefully 🙂
Click here to download the Source Code…
Hope it has helped you…