Add row to data table - how to populate 1st row of 2nd column?


I’m having an issue trying to add data to the 1st row of the 2nd column in my data table, in that when i try to add data to the 1st row of the 2nd column in the datatable, the data isnt added to the first row, it continues where the data from column 1 ended but continues in the 2nd column, ie when the table is exported to a CSV file it looks like this:

For my Activities, i start off with the Excel application scope which views 2 columns in an excel spreadsheet and stores the values for those columns in a system.collections.generic.IEnumerable<system.object.

I then create a data table and successfully populate the 1st column with the values i got from from column 1 on the Excel spreadsheet, i used a For loop for this which worked fine, ie

problem is that you are using “add row activity”. It is checking whole row when row is empty then its adding values in column. In simple words you have already utilized all the rows that’s why its adding from end of first column.
To solve this problem and to update column2 please use Update datarow activity.

Hi, my post was posted by mistake before i could enter all of the info…but i’ll try that now thanks

Hi @sam.greenwood

Try this way

  • In your build data table use only one column and first you populate the build datatable and write them in the excel first
  • Clear datatatable and them populate the datatable with 2nd column.
  • Read the output written before and store in Dt_ForColumnCount
  • Write range the second column in teh cell of (Dt_ForColumnCount.Columns.Count+1).ToString


Yes Try with this one

Hi, ok so ive added an Update Row Item activity, but i’m getting an error as i’m not sure what value to add to the row field

I want it to start off at the first row of the 2nd column then when there is a value to add just keep adding it to the next row downin the 2nd column…any idea what i should put in the Row field?


use for each for datatable and give DT,
inside for each use “Update row item”
in update row item ->value section give value
in row give ->Current Row


are you adding the data to excel from 2 different data source ?

lets say for column 1 from one source and columns 2 from another source?

Hello @sam.greenwood

I hope you are getting 2 datatable and you want to write that to respective columns in an excel sheet.

You can do as below and attached a sample project for your reference. (74.2 KB)


Hi, thanks for your response, unfortunately i need to write to a CSV file and not an excel file

Hi, thanks for your response
Ive made some progress using this activity as recommended

Data is now being written from the first row in both column 1 & Column 2, great

The next issue i’m having (hopefully the last) is that the values being written from the array into the CSV are being written as ‘System.Collections.Generic.IEnumerable`1[System.Object]


How do i change the values to a readable format

Ive tried {column2.ToString()), column2.ToString() but nothing seems to work

When populating the first column, i get the correct values displayed, the only difference is when i populate the first column i just used a For each and not a For each row in the database activity

Any ideas?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.