How to add Data to new Excel Column

In this tutorial , we will see how we can add data to a Excel Column/DataTable.

  • Implementation in UiPath

Example-

I have an Excel file which contains below data, now I need to add a new Column and add data to it.

Step 1:-

Firstly, we will use the Read Range activity to read the data of the excel file and store it to the output variable DTRange.

Uploading: image.png(1)…

Step 2:-

Now, We will use the Assign Activity and provide the new Column Name i.e ‘Not On us Check’.

image

Step 3:-

Drag the ‘Add Data Column’ activity of UiPath and pass the New Column name strNewColumn to the datatable DTRange

image

Step 4:-

We will now use ‘Write Range’ activity of UiPath to write the data into the Excel file.

image

Step 5:-

Run the workflow to check the result.

image

New column has been added into the Excel file.

  • Now our goal is to add the data into the New Column.

Step 6:-

To add the data into the newly added column, we will use Assign activity before Write Range.

image

We want to add 100 into the first row that is at index 0 and new Column which is at Column index 2.

Note:- If we enable ‘Add Headers’ property as we did here in Read Range activity then the first row would the first row after the headers which is at index 0.

Similarly, we add more data into the new column .

We want to add 100 into the first row that is at index 0 and new Column which is at Column index 2.

image

Step 7:-

Lets run the complete workflow & check the result.

I hope you enjoyed learning it.

Happy Automation !

1 Like

@Nitya1 Can you give example using loop , like data should be filled in C column along with header via looping i cant use assign dtrange.rows().item() if there are 20 or more rows in excel

Hi @Pogboom

  1. Read the excel range.
  2. Use for each loop on the datatable.
  3. Inside the loop , use the below assign activity
    row.Item(“Column C”)=“Test”
  4. Write the data to the excel sheet.
    This way you can fill the data in the specific column of the excel.

which activities to use work book one?

Hi @Pogboom
Use Excel Application Scope activity and pass the workbook name on which you want to work upon.

image
is this correct??
If yes then what will data in cell section and as well as cell content?