How To Count Rows In DataTable – In UiPath

While working with Excel, sometimes it’s necessary to find the number of records available in it.

Let’s see how to do that!!!

total_Count = my_DataTable.Rows.Count

my_DataTable : The DataTable you are working with


Implementation using UiPath :

Let us implement a workflow to count the total number of rows in Excel.

Step 1:
Drag “Excel Application Scope” activity into the designer panel and supply the “File Path” to it.
(Sample file has been attached in the link provided at the article’s end)

Count Rows In DataTable 0                   Count Rows In DataTable 1

Step 2:
Drag “Read Range” activity to read the Excel data and pass the mandatory fields to it like “Sheet Name” and output DataTable variable

Count Rows In DataTable 2Count Rows In DataTable 3

Step 3:
Drag “Message Box” activity to display the rows count.

Count Rows In DataTable 4.PNG

Step 4:
Now, run the code !!!

Count Rows In DataTable 5.PNG

Click here to download the Source Code…

Hope it has helped you…

Leave a Reply