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