Description Usage Arguments Value Examples
Wrapper for openxlsx to easily output a data frame as an excel spreadsheet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | save_xlsx(
data = NULL,
file.name = NA,
file.location = NA,
apply.header = FALSE,
header.title = NA,
header.font.style = "Arial",
header.font.size = 12,
header.font.colour = "008C98",
apply.style = FALSE,
borders = NA,
start.rows = NA,
start.cols = NA,
body.wrap.text = FALSE,
body.valign = "center",
body.halign = "left",
withFilter = NA
)
|
data |
vector of strings containing the name(s) of data frame objects |
file.name |
the file name of the excel file, excluding the path and extension details |
file.location |
the file path to save the file, by default, this is the project home folder |
apply.header |
default is |
header.title |
a string vector to override the default data frame object names in the header output. The length of this vector must equal the number of data frames |
header.font.style |
string vector options are limited to standard font styles |
header.font.size |
integer value |
header.font.colour |
hex colour format without the hash (#) prefix |
apply.style |
logical argument to include a standard styling to the output. Styling includes header and body styles |
borders |
string vector that applies a border style to the output data. Default is "rows". Options are "none", "surrounding", "rows", "columns", "all". Vector length should equal the number of data frame objects |
start.rows |
Vector of integers specifying the row index to insert the data. Vector length should equal the number of data frame objects |
start.cols |
Vector of integers specifying the column index to insert the data. Vector length should equal the number of data frame objects |
body.wrap.text |
wrap body text in table outputs. Logical argument with a default value of |
body.valign |
vertical alignment of body text. Default is |
body.halign |
horizontal alignment of body text. Default is |
withFilter |
vector of logical values to include filters at the column names in the spreadsheet. Default is FALSE. Vector length should equal the number of data frame objects. |
Saved data frames as .xlsx format to the required folder.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | a <- data.frame(mtcars)
b <- data.frame(letters)
sleep <- data.frame(msleep)
save_xlsx(data = c("a", "b"))
save_xlsx(data = c("a", "b"), apply.style = TRUE)
save_xlsx(data = c("a", "b"), apply.style = TRUE, start.rows = c(1, 2))
save_xlsx(data = c("a", "b"), apply.style = TRUE, start.rows = c(1, 2), start.cols = c(3, 4))
save_xlsx(data = c("a", "b", "sleep"), apply.style = TRUE, start.rows = c(1, 2, 2), start.cols = c(3, 4, 2))
save_xlsx(data = c("a", "b", "sleep"), apply.style = TRUE, file.name = "new file")
save_xlsx(data = c("a", "b", "sleep"), apply.header = TRUE)
save_xlsx(data = c("a", "b", "sleep"), apply.header = TRUE, file.location = getwd())
save_xlsx(data = c("a", "b", "sleep"), header.title = c("sheet1 header", "sheet2 header", "sheet3 header"))
save_xlsx(data = c("a", "b"), apply.style = TRUE, body.halign = "center")
save_xlsx(data = c("a", "b"), apply.style = TRUE, body.halign = c("center", "right"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.