Learn R Programming

openxlsx (version 1.0.3)

createStyle: Create a cell style

Description

Create a new style to apply to worksheet cells

Usage

createStyle(fontName = "Calibri", fontSize = 11, fontColour = "#000000",
  numFmt = "GENERAL", border = NULL, borderColour = "#000000",
  bgFill = NULL, fgFill = NULL, halign = NULL, valign = NULL,
  textDecoration = NULL, wrapText = FALSE)

Arguments

fontName
A name of a font. Note the font name is not validated.
fontColour
Colour of text in cell. A valid hex colour beginning with "#"
fontSize
Font size. A numeric greater than 0.
numFmt
Cell formatting
  • GENERAL
NUMBER CURRENCY ACCOUNTING DATE TIME PERCENTAGE FRACTION

Value

  • A style object

item

  • border
  • Bottom
  • Left
  • Right
  • TopBottom
  • LeftRight
  • TopLeftRight
  • TopBottomLeftRight
  • borderColour
  • bgFill
  • fgFill
  • halign
  • right
  • center
  • valign
  • center
  • bottom
  • textDecoration
  • strikeout
  • italic
  • underline
  • underline2
  • wrapText

itemize

  • bold

See Also

addStyle

Examples

Run this code
## 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 = "#FF0000")

# supply all colours
createStyle(border = "TopBottomLeft", borderColour = c("#FF0000","#00FF00", "#0000FF"))

Run the code above in your browser using DataLab