Learn R Programming

openxlsx2 (version 0.6.1)

create_dxfs_style: Create a custom formatting style

Description

Create a new style to apply to worksheet cells. Created styles have to be assigned to a workbook to use them

Usage

create_dxfs_style(
  font_name = NULL,
  font_size = NULL,
  font_color = NULL,
  numFmt = NULL,
  border = NULL,
  border_color = wb_color(getOption("openxlsx2.borderColor", "black")),
  border_style = getOption("openxlsx2.borderStyle", "thin"),
  bgFill = NULL,
  text_bold = NULL,
  text_strike = NULL,
  text_italic = NULL,
  text_underline = NULL,
  ...
)

Value

A dxfs style node

Arguments

font_name

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)

font_size

Font size. A numeric greater than 0. If fontSize is NULL, the workbook base font size is used. (Defaults to 11)

font_color

Color of text in cell. A valid hex color beginning with "#" or one of colors(). If fontColor is NULL, the workbook base font colors is used. (Defaults to black)

numFmt

Cell formatting. Some custom openxml format

border

NULL or TRUE

border_color

"black"

border_style

"thin"

bgFill

Cell background fill color.

text_bold

bold

text_strike

strikeout

text_italic

italic

text_underline

underline 1, true, single or double

...

...

See Also

wb_add_style()

Examples

Run this code
# do not apply anthing
style1 <- create_dxfs_style()

# change font color and background color
style2 <- create_dxfs_style(
  font_color = wb_color(hex = "FF9C0006"),
  bgFill = 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 = "Calibri",
  font_size = 11,
  font_color = wb_color(hex = "FF9C0006"),
  bgFill = wb_color(hex = "FFFFC7CE")
)

## See package vignettes for further examples

Run the code above in your browser using DataLab