Need help with adding a column in Excel

Hello,

I have a data table and I need to add a column with a header to column N which I believe is also column 13. It’s not working. What am I missing? Please see the images

Thank you
1 2

HI @mworth123

Few changes I would like to have is:

  • remove the question mark sign from the column name
  • Change the type argument to String or Int instead of Object

So, when you say its not working, what does happen when you run this? do you get any errors or do you get a different output than what we expect?

After you use read range and add column, you will need to use write range so those changes are saved in your excel file…

@bcorrea - Thank you, I am using a Save Workbook activity after the add Data Columns activity. Shouldn’t that save it?

data table is a memory object, it has no relation to the excel file…

@Lahiru.Fernando - Thank you, I’ve removed the “?” from the column name and changed the type to String. I’m not getting any error messages. It just isn’t adding the column.

Question: Where do I tell it to create the column in column N? I had 13 in the Default Value field but that doesn’t seem right.

@bcorrea - But I am saving the data table I scraped from a website to an Excel table.

you need to make changes to your data table BEFORE you use write range, or it will not reflect in the excel file…

@bcorrea - Thank you, that should solve it. Now, how do I tell it to create the column on Column N?

Check this post @mworth123

if you want to INSERT a column at a desired position, then you can use Add Data Columns, you will need some code like this:
dt.Columns.Add("Column Name", GetType(String)).SetOrdinal(11)

1 Like

well as @bcorrea mentioned you can do this
you can use Assign activity like this
dataColumnVar = dt.Columns.Add(“Column Name”, GetType(String)).SetOrdinal(11)
cheers
@mworth123

that wont work because setordinal is not a function it is a method and wont return anything…

@bcorrea - Thank you, where do I insert this code?


Dont forget the parameter with IN, Int32, 11

1 Like