
Last chance! 50% off unlimited learning
Sale ends in
Create a new style to apply to worksheet cells. These styles are used in conditional formatting and in (pivot) table styles.
create_dxfs_style(
font_name = NULL,
font_size = NULL,
font_color = NULL,
num_fmt = NULL,
border = NULL,
border_color = wb_color(getOption("openxlsx2.borderColor", "black")),
border_style = getOption("openxlsx2.borderStyle", "thin"),
bg_fill = NULL,
fg_color = NULL,
gradient_fill = NULL,
text_bold = NULL,
text_strike = NULL,
text_italic = NULL,
text_underline = NULL,
...
)
A dxfs style node
A name of a font. Note the font name is not validated.
If font_name
is NULL
, the workbook base_font
is used. (Defaults to Calibri), see wb_get_base_font()
Font size. A numeric greater than 0. By default, the workbook base font size is used. (Defaults to 11)
Color of text in cell. A valid hex color beginning with "#"
or one of colors(). If font_color
is NULL, the workbook base font colors is used.
(Defaults to black)
Cell formatting. Some custom openxml format
NULL
or TRUE
"black"
"thin"
Cell background fill color.
Cell foreground fill color.
An xml string beginning with <gradientFill>
...
bold
strikeout
italic
underline 1, true, single or double
Additional arguments
It is possible to override border_color and border_style with {left, right, top, bottom}_color, {left, right, top, bottom}_style.
wb_add_style()
wb_add_dxfs_style()
Other style creating functions:
create_border()
,
create_cell_style()
,
create_colors_xml()
,
create_fill()
,
create_font()
,
create_numfmt()
,
create_tablestyle()
# do not apply anything
style1 <- create_dxfs_style()
# change font color and background color
style2 <- create_dxfs_style(
font_color = wb_color(hex = "FF9C0006"),
bg_fill = wb_color(hex = "FFFFC7CE")
)
# change font (type, size and color) and background
# the old default in openxlsx and openxlsx2 <= 0.3
style3 <- create_dxfs_style(
font_name = "Aptos Narrow",
font_size = 11,
font_color = wb_color(hex = "FF9C0006"),
bg_fill = wb_color(hex = "FFFFC7CE")
)
## See package vignettes for further examples
Run the code above in your browser using DataLab