Learn R Programming

openxlsx2 (version 0.3.1)

wb_add_fill: add fill for cell region

Description

wb wrapper to create fill for cell region

Usage

wb_add_fill(
  wb,
  sheet = current_sheet(),
  dims = "A1",
  color = wb_colour(hex = "FFFFFF00"),
  pattern = "solid",
  gradient_fill = "",
  every_nth_col = 1,
  every_nth_row = 1
)

Value

The wbWorksheetObject, invisibly

Arguments

wb

a workbook

sheet

the worksheet

dims

the cell range

color

the colors to apply, e.g. yellow: wb_colour(hex = "FFFFFF00")

pattern

various default "none" but others are possible: "solid", "mediumGray", "darkGray", "lightGray", "darkHorizontal", "darkVertical", "darkDown", "darkUp", "darkGrid", "darkTrellis", "lightHorizontal", "lightVertical", "lightDown", "lightUp", "lightGrid", "lightTrellis", "gray125", "gray0625"

gradient_fill

a gradient fill xml pattern.

every_nth_col

which col should be filled

every_nth_row

which row should be filled

See Also

Other styles: wb_add_border(), wb_add_cell_style(), wb_add_font(), wb_add_numfmt(), wb_clone_sheet_style()

Examples

Run this code
wb <- wb_workbook() %>% wb_add_worksheet("S1") %>% wb_add_data("S1", mtcars)
wb <- wb %>% wb_add_fill("S1", dims = "D5:J23", color = wb_colour(hex = "FFFFFF00"))
wb <- wb %>% wb_add_fill("S1", dims = "B22:D27", color = wb_colour(hex = "FF00FF00"))

wb <- wb %>%  wb_add_worksheet("S2") %>% wb_add_data("S2", mtcars)

gradient_fill1 <- '


'
wb <- wb %>% wb_add_fill("S2", dims = "A2:K5", gradient_fill = gradient_fill1)

gradient_fill2 <- '


'
wb <- wb %>% wb_add_fill("S2", dims = "A7:K10", gradient_fill = gradient_fill2)

Run the code above in your browser using DataLab