Add data row in new columns to an existing DT i got from excel

Hi everyone
I have a Datatable from an excel file
I have in there something like 20 columns and more rows than I can count.
I took all the data from the DT I got and did some stuff (insert the data to a webpage etc.)
after that, I want to insert new data to my excel file (in a new file).
I have 7 new columns that I need to append the existing ones… (I know the names of the new columns).
and of course, insert the data into them (in the correct row).
for example, this is the input I get


and this is the output that I need to add

if u will notice after the FCW header there is 7 new columns (it’s in Hebrew)
please help me!!!

Hi @dlichtenstadt

You can use add data column activity to add new columns to the datatable. go for a for each row and add the information to these columns

If you want to order the columns put a assign and

datatable =datatable.DefaultView.ToTable(False,“ColumnName1”,“ColumnName2”,“ColumnName2”)

Keep comma and add remaining columns in which order you needs.

Please mark as a solution if you found this useful :slight_smile:

@unknownay
and after that how do i add it into the excel file? and also how do i insert the data to the right places?

Use a write range activity to write it back to excel. Using for each row activity loop through the datatable and keep in right place

I did a for each row that check if the first row is headers if so - then write cell… (all my new columns are now in, append the table i already had)
now i want to write a new data into a specific column (the name of the column is “treasury”, i have 6 others like “green”, “check”, etc.), in the correct row (the row that i’m in now (the row that i took my previous data from))

Im trying to write the data to a cell inside the for each row with the Range=“V”+row.ToString (the V is because this is the column in the excel file that i want to write in it)

image

this is the ERROR I’m getting: “Write Cell: The range VSystem.Data.DataRow does not exist.”
thank U