cell_style
cell_style.Rd
cell_style
Arguments
- rows
indices of the rows to which the style should be applied
- colnames
names of the columns to which the style should be applied
- style
style created with openxlsx::createStyle() that will be applied to the selected cells
- gridExpand
see ?openxlsx::addStyle: Apply style only to the selected elements (set gridExpand = FALSE) or to all combinations?
- stack
should the style be added to existing styles (TRUE) or overwrite existing styles (FALSE)
Examples
library(tabelle)
data("iris")
tbl <- tabelle(data = iris[iris$Species == "setosa", ],
formula = Species ~ (Sepal = Sepal.Length + Sepal.Width) +
(Petal = (Width = Petal.Length) + Petal.Width))
# To apply a custom style to some elements use the styles argument. The following
# applies the "bold" style to the rows 1-5 of the Sepal.Length column and
# the rows 9-10 of the Petal.Width column.
bold <- openxlsx::createStyle(textDecoration = "bold")
wb <- write_tab(tbl = tbl,
styles = tab_styles(cell_styles = list(cell_style(rows = 1:5,
colnames = "Sepal.Length",
style = bold),
cell_style(rows = 9:10,
colnames = "Petal.Width",
style = bold))))
# saveWorkbook(wb, "iris.xlsx")