File: addStyle.Rd

package info (click to toggle)
r-cran-openxlsx 4.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,328 kB
  • sloc: cpp: 1,867; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 1,720 bytes parent folder | download
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{addStyle}
\alias{addStyle}
\title{Add a style to a set of cells}
\usage{
addStyle(wb, sheet, style, rows, cols, gridExpand = FALSE, stack = FALSE)
}
\arguments{
\item{wb}{A Workbook object containing a worksheet.}

\item{sheet}{A worksheet to apply the style to.}

\item{style}{A style object returned from createStyle()}

\item{rows}{Rows to apply style to.}

\item{cols}{columns to apply style to.}

\item{gridExpand}{If \code{TRUE}, style will be applied to all combinations of rows and cols.}

\item{stack}{If \code{TRUE} the new style is merged with any existing cell styles.  If FALSE, any
existing style is replaced by the new style.}
}
\description{
Function adds a style to a specified set of cells.
}
\examples{
## See package vignette for more examples.

## Create a new workbook
wb <- createWorkbook("My name here")

## Add a worksheets
addWorksheet(wb, "Expenditure", gridLines = FALSE)

## write data to worksheet 1
writeData(wb, sheet = 1, USPersonalExpenditure, rowNames = TRUE)

## create and add a style to the column headers
headerStyle <- createStyle(
  fontSize = 14, fontColour = "#FFFFFF", halign = "center",
  fgFill = "#4F81BD", border = "TopBottom", borderColour = "#4F81BD"
)

## style for body
bodyStyle <- createStyle(border = "TopBottom", borderColour = "#4F81BD")
addStyle(wb, sheet = 1, bodyStyle, rows = 2:6, cols = 1:6, gridExpand = TRUE)
setColWidths(wb, 1, cols = 1, widths = 21) ## set column width for row names column
\dontrun{
saveWorkbook(wb, "addStyleExample.xlsx", overwrite = TRUE)
}
}
\seealso{
\code{\link[=createStyle]{createStyle()}}

expand.grid
}
\author{
Alexander Walker
}