This function is a wrapper for openxlsx::conditionalFormatting() allowing for a more convenient application of conditional formatting to a sheet in a Workbook object. The arguments colourScale, contains and expression serve as shortcuts to obtaining the respective conditional formatting, but it is still possible to obtain all possible conditional formatting styles available in openxlsx via the arguments rule, style and type which are directly passed to openxlsx::conditionalFormatting().

cond_format(
  wb,
  sheetName = NULL,
  columns,
  colourScale = NULL,
  contains = NULL,
  expression = NULL,
  type = NULL,
  rule = NULL,
  style = openxlsx::createStyle(fontColour = "white", bgFill = "#ad0000"),
  ...
)

Arguments

wb

a Workbook object

sheetName

a name or index of a worksheet

columns

column names or indices to apply conditional formatting to

colourScale

shortcut argument to apply "colourScale" formatting, e.g. c("red" = 0, "grey" = 50, "green" = 100)

contains

shortcut argument to apply "contains" formatting, e.g. "word"

expression

shortcut argument to apply "expression" formatting, e.g. ">=50"

type

directly passed to openxlsx::conditionalFormatting()

rule

directly passed to openxlsx::conditionalFormatting()

style

directly passed to openxlsx::conditionalFormatting(). By default, cells will have a red fill and white font color.

...

directly passed to openxlsx::conditionalFormatting()