Learn R Programming

openxlsx2 (version 0.3.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_colour(getOption("openxlsx2.borderColour", "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

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. 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_colour(hex = "FF9C0006"),
  bgFill = wb_colour(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_colour(hex = "FF9C0006"),
  bgFill = wb_colour(hex = "FFFFC7CE")
)

## See package vignettes for further examples

Run the code above in your browser using DataLab