Subscribe

UiPath Studio

The UiPath Studio Guide

Data Table Variables

DataTable variables represent a type of variable that can store big pieces of information, and act as a database or a simple spreadsheet with rows and columns. They can be found in the Browse and Select a .Net Type window, under the System.Data namespace (System.Data.DataTable). For more information, see Browsing for .Net Variable Types.

These variables can be useful to migrate specific data from a database to another, extract information from a website and store it locally in a spreadsheet and many others.

Example of Using DataTable Variables

To exemplify how you can use DataTable variables, we are going to create an automation that reads only two out of multiple columns from an Excel spreadsheet, and then transfers them to another spreadsheet that already contains other information.

The initial file is a database of people, transactions, dates, and products. In this example, we are going to extract their names and order dates and append them to an Excel spreadsheet that already contains similar information.

  1. Create a new sequence.
  2. Add an Excel Process Scope activity. This activity opens or reuses Excel processes, loads the Excel project settings, and applies them to the associated Excel file.
  3. Add a Use Excel File activity to the sequence. This activity is required for most of the Excel-related activities.

📘

Note:

If you do not have Excel activities installed on your version of UiPath, use the Manage Packages functionality to get them.

  1. Create two DataTable variables, dt_NamesList and dt_DateInfo. These are going to be used to store information from the initial Excel spreadsheet.
  2. In the Properties panel, in the Workbook path field, type the path of the initial Excel file to be used, between quotation marks.
  3. Add two Read Range activities and place them one under the other, in the Use Excel File activity. These are used to get information from the initial spreadsheet.
  4. Select the first Read Range activity. On the right side of the Range field, select Plus plus button > Excel > Indicate in Excel.
  5. Inside the Excel file, indicate the coordinates that tell UiPath Studio from where to extract information (in our case, "G7:G37"). Click Confirm after selecting the range.
  6. In the Save to field, type the name of the first DataTable variable, dt_NamesList. This variable stores all the information available between the G7 and G37 rows.
  7. (Optional) Change the value in the DisplayName field to Read Names, so you can easily tell apart this activity from the second one.
  8. Select the second Read Range activity. On the right side of the Range field, select Plus plus button > Excel > Indicate in Excel.
  9. Inside the Excel file, indicate the coordinates that contain the order date we want to extract (in our case, "C7:C37"). Click Confirm after selecting the range.
  10. In the Save to field, specify the dt_DateInfo variable. This variable retains all the date information we require.
  11. Add a second Use Excel File activity to the sequence.
  12. In the Properties panel, in the Workbook path field, type the path of the Excel file to be used to store all the information gathered at the previous steps.
  13. Add a Write DataTable to Excel activity to the Designer panel, under the second Use Excel File. This activity is used to write the stored information to another Excel file.

📘

Note:

The file used with the Write Range activity has to be closed when you run the project. If it is not closed, an error is displayed and the automation execution stops.

  1. In the What to write field, type the dt_NamesList variable.
  2. On the right side of the Destination field, select Plus plus button > Excel > Indicate in Excel.
  3. Inside the second Excel file, select the starting cell in which information from the initial file is to be added (in our case, "B7"). Click Confirm.
  4. Add another Write DataTable to Excel activity and place it under the first one.
  5. In the What to write field, type the dt_DateInfo variable.
  6. On the right side of the Destination field, select Plus plus button > Excel > Indicate in Excel.
  7. Select the starting cell (in our case, "A7"). Click Confirm.
597
  1. Press F5. Your automation is executed.
  2. Double-click the final Excel file. Note that the copied information is available, and correctly updated.
628

Download example

Updated 3 months ago


Data Table Variables


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.