Adding data to a particular column

excel
activities

#1

I have an excel sheet with n number of columns.

  1. I need to add a column (say “XYZ”) to that sheet.
  2. I need to fetch the index of that column and add data to each of the rows in that column.

How can I achieve this ?

Kindly help.


#2

can u pls refer this

Regards
B.S


#3

Doesn’t help. Kindly provide a detailed explanation.

I have the entire sheet saved in a datatable Dt. I have added a column to Dt using “Add Data Column”. Now I need to add data to that column.

The data needs to be a concatenation of the 3rd and 7th columns.

How can we achieve this ?


#4

Hi @susbasu,

  1. Use a for each row loop thru the datatable
  2. Use an assign activity to get the specific column from each row:
    row.Item(“column8”) = row.Item("Col3) + row.ITem(“Col7”)

If you need to update a specific col in a specific row then the syntax would be like:
dt.Rows(rownum).Item(“ColName”) = value

You can also use LINQ queries to achieve the same.

Feel free to lookup in the forum, someone might already have posted a solution.

Happy automating!


#5

Thanks Priya!

Have tried Excel’s “Concatenate” formula in the Write Cell activity and ran a for loop through the table. Consumes a hell of time though.

Let me try the one you suggested! Any idea how much time it takes to write 6000 rows using the approach you mentioned ?

Appreciate your efforts!

Thanks,
Sush


#6

I know for sure it works flawlessly, but not sure how long it would take. Please try and let me know how long it takes for you.

Thanks!


#7

Another way is create a DataColumn Variable say “newCol”

using Assign Activity

newCol = dt.Columns.Add("XYZ", GetType(String), "[Col 3 Name]+[Col 7 Name]")


#8

Thanks Vinay! This worked!