How to Change The Color of a Specific Row of Excel

Hi everyone,

I want to paint the entire line with the word “Total” in the “Expense” column.

Where should i write this Range area in the properties of Set Range Color activity. Or how can i do that in another way?

Hi
–once after getting the datatable named dt pass that as input to FOR EACH ROW activity
–inside the loop use a IF condition like this
row(“Expense”).ToString.Contains(“Total”)
if that is true it will go to THEN part where we can use SET RANGE COLOR activity and mention the range like this
“A”+(dt.Rows.Index(row)+2).ToString+“:”+(Convert.ToChar(dt.Columns.Count+1+65)).ToString+(dt.Columns.Count+1).ToString

this will set that row in to color in excel
Cheers @mazlumkacar

Thanks a lot. But i do not understand why are write this inside “range” area.

To specify the color at specific row we have to pass expression in range.

Thanks
@mazlumkacar

@hasib08 @Palaniyappan but i am getting this error when i try to write it

1 Like

Fine
is the variable dt_bfgrup is of type datatable and is passed to FOR EACH ROW activity
@mazlumkacar

@mazlumkacar,

use UiPathTeam.Excel.Extensions.Activities, you can easily do it with that package…

Let me know if you need further assistance.

1 Like

@sarathi125
i did it with yor way and it is worked. it changed color all of excel page. But I just want to paint the line that says “Toplam Tutar” in the “Gider Çeşidi” column. How should i write in if statement? Where am i do wrong?

@Palaniyappan

Use select range activity to select the range you want to color, then use fill color

Instead of equals try with contains
row(“yourcolumnname”).ToString.Contains(“your keyword”)

Cheers @mazlumkacar

1 Like

@sarathi125 but the range that i want to select is already written in if statement. What should i write inside select range activity? When i choose the “entire row” button, it paint only header row.

image

@Palaniyappan i did it but it is not working.

i only need to change format of a row that contains “keyword”. But do not understand why is that not working.

When i do that it change the color of all page.

1 Like

Did you solve the problem?. Because the thing I’m trying to do is same. Can’t paint the specific row.

Hey, Here is the right range code →

"A"+(full_data_table.Rows.IndexOf(row)+1).ToString+":"+(Convert.ToChar(full_data_table.Columns.Count+64)).ToString+(full_data_table.Rows.IndexOf(row)+1).ToString

2 Likes