Learn R Programming

XLConnect (version 1.0.7)

saveWorkbook-methods: Saving Microsoft Excel workbooks

Description

Saves a workbook to the corresponding Excel file. This method actually writes the workbook object to disk.

Usage

# S4 method for workbook,missing
saveWorkbook(object,file)
# S4 method for workbook,character
saveWorkbook(object,file)

Arguments

object

The workbook to save

file

The file to which to save the workbook ("save as"). If not specified (missing), the workbook will be saved to the workbook's underlying file which is the file specified in loadWorkbook (also see the workbook class for more information). Note that due to currently missing functionality in Apache POI, workbooks can only be saved in the same file format - i.e. if the workbooks underlying file format is xls, then the file argument may only specify another xls file. Also note that when specifying the file argument the workbook's underlying filename changes to reflect the "save as" behavior.
Paths are expanded using path.expand.

Author

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

Details

Saves the specified workbook object to disk.

See Also

workbook, loadWorkbook

Examples

Run this code
if (FALSE) {
# Create a new workbook 'saveMe.xlsx'
# (assuming the file to not exist already)
wb <- loadWorkbook("saveMe.xlsx", create = TRUE)

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

# Write built-in dataset 'mtcars' to sheet 'mtcars' created above
writeWorksheet(wb, mtcars, sheet = "mtcars")

# Save workbook - this actually writes the file 'saveMe.xlsx' to disk
saveWorkbook(wb)

# clean up 
file.remove("saveMe.xlsx")
}

Run the code above in your browser using DataLab