Write in Data Table

Hello everyone !

I have a request. I have to update a cell in data table but i don’t know how i can process. I tested an assign activity but doesn’t work or maybe i did a mistake.

Could you help me please ?

If you know which cell you want to update you can use the Write Cell Activity.

2 Likes

@TimK

It is not in a Excel file but on a data table but thank you

1 Like

Ok can you share what you are using in your assign?

Also which column / row etc you are trying to update?

2 Likes

@TimK Thank for your help and reply,

This is my data table that i read on Excel File. But i want to work directly on my data table.

Forum UiPath(1).xlsx (11.3 KB)

I want to update the cell “C8” on my data table.

2 Likes

@BaptisteC


DataTable.Rows[1]["Product_name"] = "Value" 
Where 1 referes to row number
3 Likes

to update C8
the expression would be
in assign activity
yourdatatablename.Rows(7)(2) = "yourvalue"

where 7 is the row index
2 is the column index

as both starts from 0 for first row and first column

Cheers @BaptisteC

2 Likes

@Palaniyappan beat me to it :stuck_out_tongue:

Learning about datatables will help and 0 index is key.

1 Like

Thank for your reply @Palaniyappan and @sandeep13 and @TimK

Can i put an index instead of the row index (7 on your example) ? Because i put my assign on a for each

you mean a variable with that index value
yes you can
yourdatatablename.Rows(yourindexvariable)(2) = "yourvalue"
make sure that indexvariable is of type int32

Cheers @BaptisteC

3 Likes

yes you can index must be int32 type

3 Likes

@sandeep13 @Palaniyappan @TimK

Thanks for your rapidity ! I will test this :slight_smile:

2 Likes

@sandeep13 @Palaniyappan

if i can enjoy your skills :stuck_out_tongue:

How can i update a part of my cell (substring) ?

Thanks :slight_smile:

1 Like

yes with this
yourstring.SubString(startingindex, no of characters)
for example
strinput = “abcdef” is the string
strinput.SubString(0,3) = will give me “abc”
0 is the start index
3 is the number of characters to be obtained

Cheers @BaptisteC

1 Like

@BaptisteC

DataTable.Rows[1][“Product_name”] =DataTable.Rows[1][“Product_name”].ToString.replace(“string”,“String”)

3 Likes