Learn R Programming

openxlsx (version 1.0.3)

replaceStyle: Replace an existing cell style

Description

Replace a style object

Usage

replaceStyle(wb, index, newStyle)

Arguments

wb
A workbook object
index
Index of style object to replace
newStyle
A style to replace the exising style as position index

See Also

getStyles

Examples

Run this code
## load a workbook
wb <- loadWorkbook(xlsxFile = file.path(path.package("openxlsx"), "loadExample.xlsx"))

## create a new style and replace style 2

newStyle <- createStyle(fgFill = "#00FF00")

## replace style 2
getStyles(wb) ## prints styles
replaceStyle(wb, 2, newStyle = newStyle)

## Save workbook
saveWorkbook(wb, "replaceStyleExample.xlsx", overwrite = TRUE)

Run the code above in your browser using DataLab