Add Rows to DataTables in UiPath |Video upload date:  · Duration: PT7M15S  · Language: EN

Learn practical ways to add rows to UiPath DataTables using Add Data Row and VB expressions for reliable automation

If you are building UiPath workflows and treating DataTables like disposable shopping lists you are doing it wrong but also welcome. This guide gives a compact and slightly cheeky walkthrough for adding rows to a UiPath DataTable while keeping types honest and Excel from throwing a tantrum.

Set up the DataTable schema first

Start by deciding the schema. Use Build Data Table for new schemas or Read Range to grab the structure from an existing sheet. Matching column types up front saves you debugging time and those fun runtime errors that smell like regret.

  • Build Data Table when creating a new table by hand
  • Read Range when you need the Excel headers and types
  • Use DataTable.Clone to copy just the schema when you need an empty shell

Add simple rows fast with Add Data Row activity

When your row values are already in order use the Add Data Row activity and supply an ArrayRow. It is the fastest path and perfect for designers who prefer boxes over raw code.

' Example ArrayRow property value
{ "Alice", CInt("30"), DateTime.Parse("2020-01-01") }

Make sure the values match the column order and types. If your data arrives as an object array this is the one click win.

Create a DataRow when you need control

If you need per column logic or want to address columns by name create a DataRow programmatically. It avoids surprises when column order changes and gives you space to convert values cleanly.

' Create and fill a DataRow
Dim row As DataRow = dt.NewRow()
row("Name") = "Bob"
row("Age") = CInt("42")
row("StartDate") = DateTime.Parse("2021-05-01")
dt.Rows.Add(row)

Using column names improves readability and reduces bugs when your teammate renames the second column to Something Creative.

When to use ImportRow or Merge

Combining tables is a real thing you will do when aggregating multiple sources. Use ImportRow to copy individual DataRow objects into another DataTable while preserving row state. Use Merge to combine whole tables and preserve schema alignment and constraints.

' Merge example
dtMain.Merge(dtToMerge)

' ImportRow example
For Each r As DataRow In dtOther.Rows
    dtMain.ImportRow(r)
Next

Type conversions and column mapping

Never trust raw strings to match column types. Use VB conversions such as CInt and DateTime.Parse when populating columns. You can assign by index or by name but name mapping is safer when column order changes.

Persisting results back to Excel

When you are done write the table back to Excel with Write Range. If you only copied schema earlier remember to import or merge the data first. Write Range will take care of the file side so your robot can sleep at night.

Quick checklist before you push to production

  • Confirm schema with Build Data Table or Read Range
  • Choose Add Data Row for simple arrays or NewRow plus Rows.Add for column logic
  • Use CInt or DateTime.Parse where types must match
  • Use Merge to combine tables and ImportRow to copy rows one by one
  • Call DataTable.Clone when you want the schema without the baggage
  • Write Range to persist changes back to Excel

There you go. Same technical truths, less ceremony, and a few jokes to keep you human while UiPath does the boring heavy lifting.

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.