Learn R Programming

openxlsx (version 4.2.6.1)

cloneWorksheet: Clone a worksheet to a workbook

Description

Clone a worksheet to a Workbook object

Usage

cloneWorksheet(wb, sheetName, clonedSheet)

Value

XML tree

Arguments

wb

A Workbook object to attach the new worksheet

sheetName

A name for the new worksheet

clonedSheet

The name of the existing worksheet to be cloned.

Author

Reinhold Kainhofer

Examples

Run this code
## Create a new workbook
wb <- createWorkbook("Fred")

## Add 3 worksheets
addWorksheet(wb, "Sheet 1")
cloneWorksheet(wb, "Sheet 2", clonedSheet = "Sheet 1")

## Save workbook
if (FALSE) {
saveWorkbook(wb, "cloneWorksheetExample.xlsx", overwrite = TRUE)
}

Run the code above in your browser using DataLab