xlsx_write.xlsx | R Documentation |
Write a data.frame to an Excel workbook
xlsx_write.xlsx(
x,
file,
sheetName = "Sheet1",
col.names = TRUE,
row.names = FALSE,
append = FALSE,
showNA = FALSE,
forceAppend = FALSE
)
x |
a data.frame to write to the workbook. |
file |
the path to the output file. |
sheetName |
a character string with the sheet name. |
col.names |
a logical value indicating if the column names of x are to be written along with x to the file. |
row.names |
a logical value indicating whether the row names of x are to be written along with x to the file. |
append |
a logical value indicating if x should be appended to an existing file. If TRUE the file is read from disk. |
showNA |
a logical value. If set to FALSE, NA values will be left as empty cells. |
forceAppend |
overwrite the sheet if it exists |
This is a forked version of xlsx::write.xlsx() that avoids the error issued by attempting to write an empty data frame. If the data frame has zero rows, xlsx:::.write_block() is skipped and the file is saved with just the column names. The fork also includes a new argument forceAppend which allows to overwrite the sheet if it already exists.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.