Learn R Programming

openxlsx (version 4.2.3)

loadWorkbook: Load an existing .xlsx file

Description

loadWorkbook returns a workbook object conserving styles and formatting of the original .xlsx file.

Usage

loadWorkbook(file, xlsxFile = NULL, isUnzipped = FALSE)

Arguments

file

A path to an existing .xlsx or .xlsm file

xlsxFile

alias for file

isUnzipped

Set to TRUE if the xlsx file is already unzipped

Value

Workbook object.

See Also

removeWorksheet

Examples

Run this code
# NOT RUN {
## load existing workbook from package folder
wb <- loadWorkbook(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx"))
names(wb) # list worksheets
wb ## view object
## Add a worksheet
addWorksheet(wb, "A new worksheet")

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

Run the code above in your browser using DataLab