## write to working directory
write_xlsx(iris, file = temp_xlsx(), col_names = TRUE)
write_xlsx(iris,
file = temp_xlsx(),
col_names = TRUE
)
## Lists elements are written to individual worksheets, using list names as sheet names if available
l <- list("IRIS" = iris, "MTCARS" = mtcars, matrix(runif(1000), ncol = 5))
write_xlsx(l, temp_xlsx(), col_widths = c(NA, "auto", "auto"))
## different sheets can be given different parameters
write_xlsx(l, temp_xlsx(),
start_col = c(1, 2, 3), start_row = 2,
as_table = c(TRUE, TRUE, FALSE), with_filter = c(TRUE, FALSE, FALSE)
)
# specify column widths for multiple sheets
write_xlsx(l, temp_xlsx(), col_widths = 20)
write_xlsx(l, temp_xlsx(), col_widths = list(100, 200, 300))
write_xlsx(l, temp_xlsx(), col_widths = list(rep(10, 5), rep(8, 11), rep(5, 5)))
Run the code above in your browser using DataLab