Inserting Column Into Excel w/ Existing Data

I am currently working on a process that compares data from several internal systems and writes them to an excel sheet. For each system’s data we check, it is appended to the right most empty column in Excel, immediately after the data that is currently there.

How can I do this? Currently I am using a Write Range and just providing the column index but I’d like it to just write the data to the next column.

Thanks!

Hello @Tal294

For you retirement we need to consider two things.

  1. How to find the right most column
  2. What would the excel column letter for that…

To get the excel column letter, use can refer to below post
How to Write to Excel CELL index v.2 - #4 by badita

Now, to find the number of columns you already have, you can do something like this.
Do

  1. Read range to read the excel into a datatable.
  2. Now use an assign activity with the below code

DT.columns.Count
This will give you the number of columns you have.

Now refer this number to the logic provided in the link I shared above and get the excel column letter.

Now you can simply do a Write Cell activity as you know the column and write the value you need…

If you have multiple rows, do this in a loop to loop through all the rows

1 Like

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