Add Column with data in Excel

Hi guys,

I have just started work with UIPath and have some issues. I can’t understand easy task and I hope you help me. For example, have Excel file with 1 Column “Name”. I want Extract info in web and write data in second Column “Description”. So, will write my steps…

  1. Read Excel file;
  2. Took For Each Row and puted Assign (Name = row(“Name”).ToString);
  3. Took Open Browser and put Type Into (Name + “[k(enter)]”). And puted Get Text. After that Close Application.
  4. So in this finnaly step I puted Application Scope and added Write Range. In Write Range I wrote variable the same with variable Get Text. But I have error.

Help me, please, and tell me what I must to do.
Thank you in advance.

1 Like

Hi
welcome to uipath community
the steps you have used is fine
but one step to be added
so
–once after reading the excel with read range use add data column activity with column name as “Description” and in the dattable mention the variable name form read range
–then use a for each row loop and inside the loop once aafter working with web page use a assign activity like this
row(“Description”) = "your value"

now after for each row lop use a write range activty and enter that into excel file

Cheers @TattyOvva

2 Likes

Thank you very much @Palaniyappan !

Only don’t understand where I have error, could you will look. Because only copied data the first column, not info what I took in web.Main.xaml (16.0 KB)

1 Like

Maybe consider not having Open Browser (and close) inside you For Each, you can only open browser one time and use the same, to save time… :slight_smile:

3 Likes

Fine
i saw your xaml
in that along FOR EACH ROW the assign activity should be like this
row(“Description”).ToString = your-get text-outputvariable.ToString
image

and place the excel application scope outside the for each row loop that keep that as a next activity to for each row loop in the flow chart
because as you have kept the excel file inside the for each row loop it will write the datable for each iteration inside the loop

Cheers @TattyOvva

1 Like

@Palaniyappan @bcorrea Thank you for your attention, but I really don’t understand. Now I did all that you said and now have error and I don’t understand what I must to do. Could you please look xaml111 Main.xaml (18.5 KB)

  1. Add Data Column, maybe you want to set TypeArgument as String instead of Object
  2. GetTextDescription = row(“Description”).ToString may be giving you an error because the value is NULL at that point…
2 Likes

Hi @TattyOvva,

Make sure your excel is not empty and that your header’s name is the same as the info you’re reading. Also you can use “Get Row Item” which is made just for DataTables.


Also your read range will always write in b1 because you have it in the for each loop. You can use “Add Data Row” to add a row to a new datatable or to your current datatable. This must be inside the for each because we want to add each result. in the array row you will put a arrayrow this is spelled between {} like this {animal, description} so you separate by comma.
image
Also make sure that the “Add data column” type is the type of column you want to add. I think you want to add a string type not a object type.
image
2 Likes

Hi, @rmunro
You are shure I want to add a string type. I want add data my current datatable. Let me explain, I started to study Uipath and wanted to understand the principle of work using a simple example. For example, I have the names of animals in one column “Animals” and I take information on Wikipedia and want to write it in the other column “Description” opposite each animal, that’s all. So, I did what you said but now I have other error. Main.xaml (19.0 KB)
22

Please test this: Main33.xaml (19.5 KB)

Test it and have error33

can i have your excel?

Yes
Animal.xlsx (8.8 KB)

please see new excel and flow: Tests.zip (9.9 KB)

Tested and have again error: Read each row – Collection was modified; enumeration operation might not execute

OK, so i think the error is because you are adding the column in your flow, is it a problem to add the description column in excel directly?

@TattyOvva,

I have attached a small sample, please have a look …

Adding Column.zip (7.6 KB)

Ahtesham

2 Likes

Ok, no problem. If add the description column in excel directly how it is look?

Thank you very much @md.ahtesham , yes it is good sample. But don’t understand why my process not run and have an errors. I have also one question, maybe you can help me… Sometimes, when I want run one xaml another xaml opens immediately and starts. Why is this happening?

i didn’t get your question correctly…
But if you mean to say that 2nd xaml file run immediately , this is obvious . your other .xaml file will run after whenever it will find invoke workflow File activity.

If you want to allow your 2nd .xaml to have delay you can just add dealy activity . ( but manual delay is not good practice.)

If you can elaborate question i can guide you.

Thanks,
Ahtesham