I want to use the R-package 'openxlsx' to do conditional formatting of a .xlsx file, but I can't figure out how to format a cell if the value does NOT contain a certain textstring. In the following example (which works perfectly) i am formatting the cells which contains the string "OK" (but my goal is to format everything else):
library(openxlsx)
style <- createStyle(fontColour = '#9C0006', bgFill = '#FFC7CE')
wb <- openxlsx::loadWorkbook('myFile.xlsx')
openxlsx::conditionalFormatting(wb, 'Sheet1', cols = 3:7, rows=1:100, type = 'contains', rule= 'OK', style = style)
openxlsx::saveWorkbook(wb, 'myFile.xlsx')
When looking at the documentation for openxlsx i see that operators are allowed in the rule-argument, so i tried the following:
openxlsx::conditionalFormatting(wb, 'Sheet1', cols = 3:7, rows=1:100, type = 'contains', rule= '!=OK', style = style)
This still does not work, as it seems the operators are only usable when type is set to 'expression'.
It seems to me that I might be missing something very small and easy, but I have had no luck figurering out what that might be, so hopefully someone has an idea (or can tell me that it just isn't possible to do it the way I intend to)