Replace an existing cell style

Replace a style object

replaceStyle(wb, index, newStyle)

Arguments

wb

A workbook object

index

Index of style object to replace

newStyle

A style to replace the existing style as position index

See also

Author

Alexander Walker

Examples

## load a workbook wb <- loadWorkbook(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx")) ## create a new style and replace style 2 newStyle <- createStyle(fgFill = "#00FF00") ## replace style 2 getStyles(wb)[1:3] ## prints styles
#> [[1]] #> A custom cell style. #> #> Cell formatting: GENERAL #> Font name: Calibri #> Font size: 11 #> #> #> #> [[2]] #> A custom cell style. #> #> Cell formatting: GENERAL #> #> #> #> [[3]] #> A custom cell style. #> #> Cell formatting: GENERAL #> #> #>
replaceStyle(wb, 2, newStyle = newStyle) ## Save workbook if (FALSE) { saveWorkbook(wb, "replaceStyleExample.xlsx", overwrite = TRUE) }