Replace an existing cell style
Replace a style object
replaceStyle(wb, index, newStyle)
## 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
#> Font colour: 10
#> Font decoration: UNDERLINE
#> Cell horz. align: left
#>
#>
#>
#> [[2]]
#> A custom cell style.
#>
#> Cell formatting: GENERAL
#> Cell horz. align: center
#> wraptext: TRUE
#>
#>
#> [[3]]
#> A custom cell style.
#>
#> Cell formatting: GENERAL
#>
#>
#>
replaceStyle(wb, 2, newStyle = newStyle)
## Save workbook
if (FALSE) { # \dontrun{
saveWorkbook(wb, "replaceStyleExample.xlsx", overwrite = TRUE)
} # }