I guess it depends on what you call dynamic.
If you want a truly dynamic solution, then conditional formatting is the way to go.
But, it you’re constructing the Excel from scratch, that’s not always an option.
You can do it programmatically from OpenRPA, but it’s not going to be super fast for large files.
Something like this works (remember to closeworkbook with save=true in finally, otherwise you won’t see any changes)
The “just to get wb” is a read cell, we need to fetch the Workbook reference from it (unless you already have it from somewhere else).
Then in InvokeCode:
Dim worksheet = wb.Sheets(sheetName)
Dim cell = worksheet.Cells(2,4)
If (cell.Text = "Important") Then
worksheet.Cells(2,4).Interior.Color = Microsoft.Office.Interop.Excel.XlRgbColor.rgbRed
Else
worksheet.Cells(2,4).Interior.Color = Microsoft.Office.Interop.Excel.XlRgbColor.rgbGreen
End If
How to iterate throughout the cells is left as an exercise to the reader