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.
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.
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.
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.
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
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.
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.
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.