Removing worksheets from workbooks

Share:

Description

Removes a worksheet from a workbook.

Usage

1
2
3
4
## S4 method for signature 'workbook,character'
removeSheet(object,sheet)
## S4 method for signature 'workbook,numeric'
removeSheet(object,sheet)

Arguments

object

The workbook to use

sheet

The name or index of the sheet to remove

Note

When removing a worksheet that is the currently active sheet then XLConnect resets the active sheet to the first possible worksheet in the workbook.
Also note that deleting worksheets may result in invalid name references.

Author(s)

Martin Studer
Mirai Solutions GmbH http://www.mirai-solutions.com

See Also

workbook, createSheet, existsSheet, getSheets, renameSheet, cloneSheet, setActiveSheet

Examples

1
2
3
4
5
6
7
8
# mtcars xlsx file from demoFiles subfolder of package XLConnect
mtcarsFile <- system.file("demoFiles/mtcars.xlsx", package = "XLConnect")

# Load workbook
wb <- loadWorkbook(mtcarsFile)

# Remove the worksheet called 'mtcars' from the above file
removeSheet(wb, sheet = "mtcars")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.