How to find the background color of an Excel cell?

datatable
excel

#1

Hi,

I am developing a worfklow where I need to read each row of an Excel cell with a single column and check if that color is Yellow or not. If it is Yellow, I have to save the value from the column into some list (or any other structure of data).

So far, I did this:

1º Inside an ExcelApplicationScope activity, I added an ExcelReadRange activity. With that read range, I got created a new data table.

2º Since the documentation says that the ExcelGetCellColor only exists inside an ExcelApplicationScope, I made a new sequence with a ForEachRow that loops through the previously created data table.

Obs. 1: The idea in mind is looping through each row and get the cell color from each row(0).Item and save it.
Obs. 2: cCell is the name of the variable that I created for the ExcelCellColor activity

So, any tip if the current approach is the best so far? If not, what would be the recommend steps next?

Cheers.


#2

:+1:


#3

Hey @moreirasa1,
Are you sure that the file will have 50 rows exactly?
Each time in loop it will get the color of same cell since you’re not changing the offset value… you can change the cell value using a counter or using row index. Good Luck!

Best Regards,
SP


#4

@SantoshPothina Hi, the file will have more than 50 rows. I used 50 just for testing purposes on a section of the file. Anyway, regarding my question I already managed to do what I was thinking. For example, one my previous screenshot I had the ExcelApplicationScope inside a ForEachRow and that wasn’t make any sense. What I did instead was a simple Sequence, with just an ExcelApplicationScope with a ForEachRow activity.

I used IndexOf (which indeed it works similar to a counter) and for each loop, I will get the cell color of the row I’m looking for. Here’s a glimpse of what I have done:

Cheers.