| createStyle {openxlsx} | R Documentation |
Create a new style to apply to worksheet cells
createStyle(fontName = NULL, fontSize = NULL, fontColour = NULL,
numFmt = "GENERAL", 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)
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) |
numFmt |
Cell formatting
|
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 vertial text. |
indent |
Horizontal indentation of cell contents. |
A style object
Alexander Walker
## See package vignettes for further examples
## Modify default values of border colour and border line style
options("openxlsx.borderColour" = "#4F80BD")
options("openxlsx.borderStyle" = "thin")
## Size 18 Arial, Bold, left horz. aligned, fill colour #1A33CC, all borders,
style <- createStyle(fontSize = 18, fontName = "Arial",
textDecoration = "bold", halign = "left", fgFill = "#1A33CC", border= "TopBottomLeftRight")
## Red, size 24, Bold, italic, underline, center aligned Font, bottom border
style <- createStyle(fontSize = 24, fontColour = rgb(1,0,0),
textDecoration = c("bold", "italic", "underline"),
halign = "center", valign = "center", border = "Bottom")
# borderColour is recycled for each border or all colours can be supplied
# colour is recycled 3 times for "Top", "Bottom" & "Right" sides.
createStyle(border = "TopBottomRight", borderColour = "red")
# supply all colours
createStyle(border = "TopBottomLeft", borderColour = c("red","yellow", "green"))