# Create a new workbook
wb <- wb_workbook()
# Add worksheets
wb$add_worksheet("Sheet 1")
wb$clone_worksheet("Sheet 1", new = "Sheet 2")
# Take advantage of waiver functions
wb$clone_worksheet(old = "Sheet 1")
## cloning from another workbook
# create a workbook
wb <- wb_workbook()$
add_worksheet("NOT_SUM")$
add_data(x = head(iris))$
add_fill(dims = "A1:B2", color = wb_color("yellow"))$
add_border(dims = "B2:C3")
# we will clone this styled chart into another workbook
fl <- system.file("extdata", "oxlsx2_sheet.xlsx", package = "openxlsx2")
wb_from <- wb_load(fl)
# clone styles and shared strings
wb$clone_worksheet(old = "SUM", new = "SUM", from = wb_from)
Run the code above in your browser using DataLab