qstyle | R Documentation |
Wrapper to openxlsx::createStyle
to create cell styles, with additional
arguments rows
and cols
to specify the rows and/or columns that the style
should apply to.
qstyle(
rows = "data",
cols = everything(),
fontName = NULL,
fontSize = NULL,
fontColour = NULL,
border = NULL,
borderColour = getOption("openxlsx.borderColour", "black"),
borderStyle = getOption("openxlsx.borderStyle", "thin"),
bgFill = NULL,
fgFill = NULL,
halign = NULL,
valign = NULL,
textDecoration = NULL,
wrapText = FALSE,
textRotation = NULL,
indent = NULL,
locked = NULL,
hidden = NULL
)
rows |
Which rows the style should apply to. Can be set using
either: Integer rows indexes: (e.g. Expressions can optionally include a Note that conditional formatting can update in real time if relevant data is changed within the workbook. |
cols |
Tidy-selection specifying the columns that the style should apply
to. Defaults to |
fontName |
A name of a font. Note the font name is not validated. If fontName is NULL, the workbook base font is used. (Defaults to Calibri) |
fontSize |
Font size. A numeric greater than 0. If fontSize is NULL, the workbook base font size is used. (Defaults to 11) |
fontColour |
Colour of text in cell. A valid hex colour beginning with "#" or one of colours(). If fontColour is NULL, the workbook base font colours is used. (Defaults to black) |
border |
Cell border. A vector of "top", "bottom", "left", "right" or a single string).
|
borderColour |
Colour of cell border vector the same length as the number of sides specified in "border" A valid colour (belonging to colours()) or a valid hex colour beginning with "#" |
borderStyle |
Border line style vector the same length as the number of sides specified in "border"
|
bgFill |
Cell background fill colour. A valid colour (belonging to colours()) or a valid hex colour beginning with "#". – Use for conditional formatting styles only. |
fgFill |
Cell foreground fill colour. A valid colour (belonging to colours()) or a valid hex colour beginning with "#" |
halign |
Horizontal alignment of cell contents
|
valign |
A name Vertical alignment of cell contents
|
textDecoration |
Text styling.
|
wrapText |
Logical. If |
textRotation |
Rotation of text in degrees. 255 for vertical text. |
indent |
Horizontal indentation of cell contents. |
locked |
Whether cell contents are locked (if worksheet protection is turned on) |
Whether the formula of the cell contents will be hidden (if worksheet protection is turned on) |
An expression passed to the rows
argument can optionally incorporate a .x
selector to refer to multiple columns within the worksheet.
When a .x
selector is used, each column specified in arguments cols
is
independently swapped into the .x
position of the expression, which is then
translated to the Excel formula equivalent and applied as conditional
formatting to the worksheet.
For example, given the following qstyle
specification with respect to the
mtcars
dataset
qstyle( rows = .x == 1, cols = c(vs, am, carb), bgFill = "#FFC7CE" )
the style bgFill = "#FFC7CE"
would be independently applied to any cell in
columns vs
, am
, or carb
with a value of 1
.
# apply style halign = "center" to all data rows (by default rows = "data")
qstyle(halign = "center")
# apply style halign = "center" to all rows including header
qstyle(rows = "all", halign = "center")
# apply style halign = "center" to Excel rows 2:10
qstyle(rows = 2:10, halign = "center")
# apply conditional formatting to rows where cyl == 8 & mpg > 16
qstyle(cyl == 8 & mpg > 16, fgFill = "#fddbc7", textDecoration = "bold")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.