Learn R Programming

openxlsx (version 4.2.3)

renameWorksheet: Rename a worksheet

Description

Rename a worksheet

Usage

renameWorksheet(wb, sheet, newName)

Arguments

wb

A Workbook object containing a worksheet

sheet

The name or index of the worksheet to rename

newName

The new name of the worksheet. No longer than 31 chars.

Details

DEPRECATED. Use names

Examples

Run this code
# NOT RUN {
## Create a new workbook
wb <- createWorkbook("CREATOR")

## Add 3 worksheets
addWorksheet(wb, "Worksheet Name")
addWorksheet(wb, "This is worksheet 2")
addWorksheet(wb, "Not the best name")

#' ## rename all worksheets
names(wb) <- c("A", "B", "C")


## Rename worksheet 1 & 3
renameWorksheet(wb, 1, "New name for sheet 1")
names(wb)[[1]] <- "New name for sheet 1"
names(wb)[[3]] <- "A better name"

## Save workbook
# }
# NOT RUN {
saveWorkbook(wb, "renameWorksheetExample.xlsx", overwrite = TRUE)
# }

Run the code above in your browser using DataLab