Description Usage Arguments Note Author(s) Examples
to_excel allows you to pass R objects (primarily a data.frame) to
an open Workbook, and write it later with write_data. The workbook
can be created by calling excel_workbook, which is itself a wrapper for
createWorkbook.
1 2 3 4 5 6 7  | 
df | 
 A   | 
wb | 
 A   | 
title | 
 The title to give to the table. When   | 
... | 
 Arguments passed to   | 
template | 
 Optional: Specify a path if you would like to append data to an existing .xlsx file. Default creates a new workbook.  | 
sheet | 
 The sheet you want to write the data to.  | 
format | 
 Format values and apply the default template to the table output.  | 
append | 
 Whether or not the function should append to or replace the sheet before writing.  | 
row | 
 Specify the startingrow when writing data to a new sheet.  | 
col | 
 Start column. Same as for row.  | 
This function requires openxlsx.
Kristian D. Olsen
1 2 3 4 5 6 7 8 9 10 11 12 13  | if (require(openxlsx)) {
 wb <- excel_workbook()
 df <- data.frame("String" = c("A", "B"), "Int" = c(1:2L), "Percent" = c(0.5, 0.75))
 # The workbook is mutable, so we don't have to assign result.
 to_excel(df, wb, title = "Example data", sheet = "Example", append = FALSE)
 # Data is first argument, so we can use it with dplyr.
 # df %>% to_excel(wb, title = "Example dplyr", sheet = "Example", append = TRUE)
 # Save the data
 write_data(wb, "Example table.xlsx", overwrite = TRUE)
}
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.