saveWorkbook-methods | R Documentation |
Saves a workbook
to the corresponding Excel file. This method actually writes the workbook
object to disk.
## S4 method for signature 'workbook,missing'
saveWorkbook(object,file)
## S4 method for signature 'workbook,character'
saveWorkbook(object,file)
object |
The |
file |
The file to which to save the |
Saves the specified workbook
object to disk.
As already mentioned in the documentation of the
workbook
class, a workbook
's
underlying Excel file is not saved (or being created in case the file
did not exist and create = TRUE
has been specified) unless the
saveWorkbook
method has been called on the object. This provides
more flexibility to the user to decide when changes are saved and also
provides better performance in that several changes can be written in
one go (normally at the end, rather than after every operation causing
the file to be rewritten again completely each time). This is due to the
fact that workbooks are manipulated in-memory and are only written to
disk with specifically calling saveWorkbook
.
Further note that calling saveWorkbook
more than once leads to an
exception. This is due to a current issue in the underlying POI libraries.
However, with XLConnect there should be no need to call saveWorkbook
more than once so virtually this is no issue.
Martin Studer
Mirai Solutions GmbH https://mirai-solutions.ch
workbook
, loadWorkbook
## Not run:
# 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")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.