createSheet-methods: Creating worksheets in a workbook

createSheet-methodsR Documentation

Creating worksheets in a workbook

Description

Creates worksheets with specified names in a workbook.

Usage

  ## S4 method for signature 'workbook'
createSheet(object, name)

Arguments

object

The workbook to use

name

The name of the sheet to create

Details

Creates a worksheet with the specified name if it does not already exist. Note that the naming of worksheets needs to be in line with Excel's convention, otherwise an exception will be thrown. For example, worksheet names cannot be longer than 31 characters. Also note that the name argument is vectorized, so multiple worksheets can be created in one method call.

Author(s)

Martin Studer
Mirai Solutions GmbH https://mirai-solutions.ch

See Also

workbook, removeSheet, renameSheet, existsSheet, getSheets, cloneSheet

Examples

## Not run: 
# Load workbook (create if not existing)
wb <- loadWorkbook("createSheet.xlsx", create = TRUE)

# Create a worksheet called 'CO2'
createSheet(wb, name = "CO2")

# Save workbook (this actually writes the file to disk)
saveWorkbook(wb)

# clean up 
file.remove("createSheet.xlsx")

## End(Not run)

XLConnect documentation built on Sept. 11, 2024, 8:04 p.m.