1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{createStyle}
\alias{createStyle}
\title{Create a cell style}
\usage{
createStyle(
fontName = NULL,
fontSize = NULL,
fontColour = NULL,
numFmt = openxlsx_getOp("numFmt", "GENERAL"),
border = NULL,
borderColour = openxlsx_getOp("borderColour", "black"),
borderStyle = openxlsx_getOp("borderStyle", "thin"),
bgFill = NULL,
fgFill = NULL,
halign = NULL,
valign = NULL,
textDecoration = NULL,
wrapText = FALSE,
textRotation = NULL,
indent = NULL,
locked = NULL,
hidden = NULL
)
}
\arguments{
\item{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)}
\item{fontSize}{Font size. A numeric greater than 0.
If fontSize is NULL, the workbook base font size is used. (Defaults to 11)}
\item{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)}
\item{numFmt}{Cell formatting
\itemize{
\item{\strong{GENERAL}}
\item{\strong{NUMBER}}
\item{\strong{CURRENCY}}
\item{\strong{ACCOUNTING}}
\item{\strong{DATE}}
\item{\strong{LONGDATE}}
\item{\strong{TIME}}
\item{\strong{PERCENTAGE}}
\item{\strong{FRACTION}}
\item{\strong{SCIENTIFIC}}
\item{\strong{TEXT}}
\item{\strong{COMMA} for comma separated thousands}
\item{For date/datetime styling a combination of d, m, y and punctuation marks}
\item{For numeric rounding use "0.00" with the preferred number of decimal places}
}}
\item{border}{Cell border. A vector of "top", "bottom", "left", "right" or a single string).
\describe{
\item{\strong{"top"}}{ Top border}
\item{\strong{bottom}}{ Bottom border}
\item{\strong{left}}{ Left border}
\item{\strong{right}}{ Right border}
\item{\strong{TopBottom} or \strong{c("top", "bottom")}}{ Top and bottom border}
\item{\strong{LeftRight} or \strong{c("left", "right")}}{ Left and right border}
\item{\strong{TopLeftRight} or \strong{c("top", "left", "right")}}{ Top, Left and right border}
\item{\strong{TopBottomLeftRight} or \strong{c("top", "bottom", "left", "right")}}{ All borders}
}}
\item{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 "#"}
\item{borderStyle}{Border line style vector the same length as the number of sides specified in "border"
\describe{
\item{\strong{none}}{ No Border}
\item{\strong{thin}}{ thin border}
\item{\strong{medium}}{ medium border}
\item{\strong{dashed}}{ dashed border}
\item{\strong{dotted}}{ dotted border}
\item{\strong{thick}}{ thick border}
\item{\strong{double}}{ double line border}
\item{\strong{hair}}{ Hairline border}
\item{\strong{mediumDashed}}{ medium weight dashed border}
\item{\strong{dashDot}}{ dash-dot border}
\item{\strong{mediumDashDot}}{ medium weight dash-dot border}
\item{\strong{dashDotDot}}{ dash-dot-dot border}
\item{\strong{mediumDashDotDot}}{ medium weight dash-dot-dot border}
\item{\strong{slantDashDot}}{ slanted dash-dot border}
}}
\item{bgFill}{Cell background fill colour.
A valid colour (belonging to colours()) or a valid hex colour beginning with "#".
-- \strong{Use for conditional formatting styles only.}}
\item{fgFill}{Cell foreground fill colour.
A valid colour (belonging to colours()) or a valid hex colour beginning with "#"}
\item{halign}{Horizontal alignment of cell contents
\describe{
\item{\strong{left}}{ Left horizontal align cell contents}
\item{\strong{right}}{ Right horizontal align cell contents}
\item{\strong{center}}{ Center horizontal align cell contents}
\item{\strong{justify}}{ Justify horizontal align cell contents}
}}
\item{valign}{A name
Vertical alignment of cell contents
\describe{
\item{\strong{top}}{ Top vertical align cell contents}
\item{\strong{center}}{ Center vertical align cell contents}
\item{\strong{bottom}}{ Bottom vertical align cell contents}
}}
\item{textDecoration}{Text styling.
\describe{
\item{\strong{bold}}{ Bold cell contents}
\item{\strong{strikeout}}{ Strikeout cell contents}
\item{\strong{italic}}{ Italicise cell contents}
\item{\strong{underline}}{ Underline cell contents}
\item{\strong{underline2}}{ Double underline cell contents}
\item{\strong{accounting}}{ Single accounting underline cell contents}
\item{\strong{accounting2}}{ Double accounting underline cell contents}
}}
\item{wrapText}{Logical. If \code{TRUE} cell contents will wrap to fit in column.}
\item{textRotation}{Rotation of text in degrees. 255 for vertical text.}
\item{indent}{Horizontal indentation of cell contents.}
\item{locked}{Whether cell contents are locked (if worksheet protection is turned on)}
\item{hidden}{Whether the formula of the cell contents will be hidden (if worksheet protection is turned on)}
}
\value{
A style object
}
\description{
Create a new style to apply to worksheet cells
}
\examples{
## 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"))
}
\seealso{
\code{\link[=addStyle]{addStyle()}}
}
\author{
Alexander Walker
}
|