Inserting column at the end of the table using StudioX

Hello everyone,

I would like to seek some help on how to detect the last column and add new column after column F as shown in the image together with the format. I would like this feature to be dynamic so whenever I run the project in studioX it will add a new column at the end.

Thank you in advance.

image

Hi @winne.oo

You can try with “READ COLUMN” activity and get the column count Store the Result in DT.

After that use Add Data Column Activity Or Insert Column Activity and pass the Position dynamically

Dt.Column.Count+1

Regards
Gokul

Hi @Gokul001, where can I find ‘Read Column’ activity ? Cause I can’t find it under excel.

Regards, Winne.

Hi @winne.oo

Check whether that you have Installed Uipath.Excel.Activities

Find the SS for the activity

Regards
Gokul

Hello @Gokul001,

I have installed Uipath.Excel.Activities as shown in the picture. But I still could not find ‘Read Column’ activity under the excel category.

Regards,
Winnie

Hi @winne.oo

Disable the Modern design experience

Regards
Gokul

Hello @Gokul001, I just realise that you’re using UiPath Studio and I am seeking solution for UiPath StudioX. Hence, I can’t find the settings that you asked me to disable. Thank you.

Hello,

Hmm so for one time usage you could use the insert column activity and just provide the column name after which you want to insert the new column .

For a recursive usage you will have to automatically generate the column name . Based on the assumption that the column name progression looks something like this : june-22 , july-22 , aug-22 and so forth and based on the assumption that you will run the StudioX project every month then you will have to do something like this :

  • determine the current month
  • calculate the previous month
  • insert the new column based on the previous month

The following project does just that :slight_smile:
NewBlankTask206.zip (216.1 KB)

I do have to say that this is a glass canon since if you run it twice it will throw a column already exists :slight_smile:

Regards,
Dragos

Also if you want t o use the old Excel activities in StudioX you have to enable the “Show developer” option

Regards,
Dragos.

Improving on the solution and adding some more programming one can use something like “Excel.Table(”<<name_of_target_table>>“).Columns.LastOrDefault().ToString” to obtain the last column in a specific table . Next one will have to calculate the next month using the modify date activity and the DateTime.Parse function to generate the start date from the column name ( DateTime.Parse(Excel.Table(“<<name_of_target_table>>”).Columns.LastOrDefault().ToString) )

Here’s the same project with the new modifications. Now you can run it again and again and it will insert columns :slight_smile:
NewBlankTask206_modified.zip (216.1 KB)

Regards,
Dragos.

Hello @dragos.suma, thank you so much for the solution that you provided it was a great help to me.
But I don’t know where I did wrong. I tried to do the same way as you but it’s not working on my side. Could you please give it a look and see what or where when wrong ? Your help is much appreciated thanks a lot.

image

And I would also like to ask if my data is not in a Table form can I still find the last column or row using UiPath StudioX ?

Hello,

Sorry for the late reply i was on vacation. So from what I can see you are trying to use a function into the text builder, and that’s why it’s failing :slight_smile: You would have to use the advanced editor

As per your second question you can always convert some unstructured data into a table using the “Format as Table” activity .

Regards,
Dragos

Hello @dragos.suma,

It’s ok and I hope you had a great vacation :smiley:
I tried using advance editor before but I keep getting compiler error as shown in the image which said the variable is not declared and may be inaccessible due to its protection level. Hence, I change it to text builder as it could access the variable. One more thing I realise is that under the advance editor on my StudioX top left corner shows ‘Value (Excel Value)’ but yours shows ‘Value(String)’ - I underlined it on the image. Why is there a different and how could I change it ?

Thank you.

image

Hmmm , can you share the project ? Somehow I have a feeling that you have the variable defined on a scope that is inaccessible.

Ya sure sure, I have attached the project below. Please help me to have a look at it.
Also I would like to ask do I have to always install CheckStudioRuns, BenefitsLibrary and RequiredActivities packages whenever I start a new project ? And what are these packages for ?

InsertNewColumn.zip (62.3 KB)

Thank you.