# NOT RUN {
## write to working directory
options("openxlsx.borderColour" = "#4F80BD") ## set default border colour
# }
# NOT RUN {
write.xlsx(iris, file = "writeXLSX1.xlsx", colNames = TRUE, borders = "columns")
write.xlsx(iris, file = "writeXLSX2.xlsx", colNames = TRUE, borders = "surrounding")
# }
# NOT RUN {
hs <- createStyle(
textDecoration = "BOLD", fontColour = "#FFFFFF", fontSize = 12,
fontName = "Arial Narrow", fgFill = "#4F80BD"
)
# }
# NOT RUN {
write.xlsx(iris,
file = "writeXLSX3.xlsx",
colNames = TRUE, borders = "rows", headerStyle = hs
)
# }
# NOT RUN {
## 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))
# }
# NOT RUN {
write.xlsx(l, "writeList1.xlsx", colWidths = c(NA, "auto", "auto"))
# }
# NOT RUN {
## different sheets can be given different parameters
# }
# NOT RUN {
write.xlsx(l, "writeList2.xlsx",
startCol = c(1, 2, 3), startRow = 2,
asTable = c(TRUE, TRUE, FALSE), withFilter = c(TRUE, FALSE, FALSE)
)
# }
# NOT RUN {
# specify column widths for multiple sheets
# }
# NOT RUN {
write.xlsx(l, "writeList2.xlsx", colWidths = 20)
write.xlsx(l, "writeList2.xlsx", colWidths = list(100, 200, 300))
write.xlsx(l, "writeList2.xlsx", colWidths = list(rep(10, 5), rep(8, 11), rep(5, 5)))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab