cell_style | R Documentation |
cell_style
cell_style(rows, colnames, style, gridExpand = FALSE, stack = TRUE)
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 (gridExpand = FALSE, default) or to all combinations? |
stack |
should the style be added to existing styles (TRUE) or overwrite existing styles (FALSE) |
list with specified styles
library(tablespan)
data("iris")
tbl <- tablespan(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 <- as_excel(tbl = tbl,
styles = tbl_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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.