writeWorksheet-methods | R Documentation |
Writes data to worksheets of a workbook
.
## S4 method for signature 'workbook,ANY,character'
writeWorksheet(object,data,sheet,startRow,startCol,header,overwriteFormulaCells,rownames)
## S4 method for signature 'workbook,ANY,numeric'
writeWorksheet(object,data,sheet,startRow,startCol,header,overwriteFormulaCells,rownames)
object |
The |
data |
Data to write |
sheet |
The name or index of the sheet to write to |
startRow |
Index of the first row to write to. The default is |
startCol |
Index of the first column to write to. The default is |
header |
Specifies if the column names should be written. The default is |
overwriteFormulaCells |
Specifies if existing formula cells in the |
rownames |
Name ( |
Writes data
to the worksheet specified by
sheet
. data
is assumed to be a data.frame
and is
coerced to one if this is not already the case. startRow
and
startCol
define the top left corner of the data region to be
written. Note that the arguments are vectorized and as such multiple
data objects (data.frame
's) can be written to different
worksheets in one call. In this case data
is assumed to be a list
of data.frame
s.
When writing data to Excel, writeWorksheet
further applies cell
styles to the cells as defined by the workbook
's
"style action" (see
setStyleAction
).
Martin Studer
Mirai Solutions GmbH https://mirai-solutions.ch
workbook
,
writeNamedRegion
,
appendWorksheet
,
appendNamedRegion
,
readWorksheet
,
readNamedRegion
,
writeWorksheetToFile
## Not run:
# Load workbook (create if not existing)
wb <- loadWorkbook("writeWorksheet.xlsx", create = TRUE)
# Create a worksheet called 'CO2'
createSheet(wb, name = "CO2")
# Write built-in data set 'CO2' to the worksheet created above;
# offset from the top left corner and with default header = TRUE
writeWorksheet(wb, CO2, sheet = "CO2", startRow = 4, startCol = 2)
# Save workbook (this actually writes the file to disk)
saveWorkbook(wb)
# clean up
file.remove("writeWorksheet.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.