How to create and build a DataTable in UiPath Example |Video upload date:  · Duration: PT7M5S  · Language: EN

Build and populate a DataTable in UiPath using Build Data Table Add Data Column and Add Data Row with clear step by step examples

Welcome to the thrilling world of DataTables in UiPath where spreadsheets meet mild chaos and automation makes it bearable. This guide walks you through creating a DataTable, defining columns with the Build Data Table designer or Add Data Column at runtime, populating rows with Add Data Row or bulk reads, processing rows with For Each Row, and finally exporting with Write Range or Output Data Table. Yes this is the part of RPA that looks boring but actually runs your life.

Create the DataTable variable

Start by making a DataTable variable. Give it a clear name like dt so future you does not scream at past you. In the Variables panel set the variable type to DataTable. If you like ceremonies you can use an Assign activity to initialize it with dt = New DataTable() but the Build Data Table activity will do that for you too.

Define columns with Build Data Table or Add Data Column

You have two friendly paths here. Use the Build Data Table designer when you know the schema up front. It creates named columns and data types so the rest of your workflow behaves itself. Use Add Data Column when the incoming data is unpredictable or you enjoy debugging interesting errors.

  • Build Data Table designer is fast and visual for fixed schemas
  • Add Data Column is dynamic and useful for variable input or headers from sources

Example column setup

In the designer set columns like Name as String and Age as Int32. If you prefer activities use Add Data Column to append columns while the workflow runs.

Populate the DataTable with rows

For single or few rows use Add Data Row. For bulk imports use Read CSV or Read Range then assign that output to the dt variable. Here is a tiny example of adding one row with the ArrayRow property.

ArrayRow = { "Alice", 30 }

You can also create a DataRow object, fill fields, and add it with Add Data Row. Both paths are valid and both will judge you equally.

Process rows with For Each Row

Use For Each Row to iterate and manipulate data. Access values by name like row("Name").ToString or by index. Use Assign to transform values and Write Line or Log Message to peek under the hood while debugging. Example pseudocode is below.

For Each row In dt
  name = row("Name").ToString
  age = Convert.ToInt32(row("Age"))
  ' do something like Assign and Log Message
Next

Export or inspect the DataTable

To get the DataTable into Excel use Write Range and point to a Workbook or an Excel Application Scope. For a quick console friendly view use Output Data Table to convert the table to text then Write Line. Both work and both will cheerfully leak schema issues into your logs.

Tips and gotchas

  • If your columns are dynamic validate their existence before you read them to avoid runtime surprises
  • Prefer typed conversions when reading numeric or date fields to avoid strings pretending to be numbers
  • When debugging add Write Line or Log Message inside the For Each Row to inspect values one row at a time

There you go. You now know how to build a UiPath DataTable, add columns and rows, process each row with For Each Row, and export the result with Write Range or Output Data Table. Use these patterns in your RPA projects and enjoy the rare thrill of a working workflow on the first run or at least on the second run with fewer cursed variable names.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.