Write DataTable to Excel in UiPath

Now that you know how to read data from excel, the next thing you have to learn is how to write data to excel using UiPath.

Business use case

Let’s imagine the client is asking you to create an automation which reads a table from a web page and save its content into an Excel file. For this tutorial, to keep things nice and simple, I will assume that the content of the table was already saved into a DataTable variable.

The table from the web page can be easily read using the Data Scraping Wizard.


First, let’s open the UiPath Studio and create a new process. Name it WriteDataTableToExcel.

From the Activities panel drag and drop a Sequence. Next, go and search for a Build Data Table activity. We will use it to populate the DataTable with relevant information.

Build Data Table activity

Drag and drop it inside the Sequence.

UiPath Sequence

This activity allows you to customize a new DataTable. You can add as many columns and rows as you like. To add a new column go and select the + button (next to the First Name column on the left side). Click OK after you entered all necessary data.

Build Data Table customization

The newly entered content needs to be saved into a DataTable variable. To do this you must go to the Output of the activity and using the CTRL+K shortcut, create a new variable called dtEmployee.

Build Data Table properties

So far we have the DataTable. The next step is to take the content of the DataTable and save it into an excel file. To do that we need to use an Excel Application Scope activity. Go to the Activities panel and search for it. Drag and drop it after the Build Data Table.

For the Path, we need to specify the name of the file we want to write. For this example, you can use employees.xlsx. A good practice is to create a new folder and save it there. By doing this, your project is well organized. Let’s name the folder Export. The final path is Export/employees.xlsx

Excel Application Scope activity
Folder structure


If the file doesn’t exist, a new one will be created.

Inside the Excel Application Scope, we have to place a Write Range activity. Make sure you select the activity under the Excel and NOT the one under the Workbook.

Write Range under the Excel section

Drag and drop it inside Do. Enter the DataTable you just created (dtEmployee). If there is any data into the excel file, the Write Range will overwrite it starting from A1 (Starting Cell).

Write to Excel

By default, the excel file will not contain the name of the columns (Header). To write the header as well, go to Excel Write Range properties and select the AddHeaders checkbox.

Write Range properties

The automation should look like this:

Final solution: Write DataTable to Excel in UiPath

Download the solution

Click on the button below to download the source of the demo (Write DataTable to Excel in UiPath).

Download the solution in UiPath

About Valeriu B

RPA Developer (UiPath certified)