## see package vignette for further examples.
wb <- createWorkbook()
## Add worksheets
addWorksheet(wb, "Cars")
x <- mtcars[1:6,]
writeData(wb, "Cars", x, startCol = 2, startRow = 3, rowNames = TRUE)
writeData(wb, "Cars", x, rowNames = TRUE, startCol = "O", startRow = 3,
borders="surrounding", borderColour = NULL) ## black border
writeData(wb, "Cars", x, rowNames = TRUE,
startCol = 2, startRow = 12, borders="columns")
writeData(wb, "Cars", x, rowNames = TRUE,
startCol="O", startRow = 12, borders="rows", borderColour = "#4F81BD")
## header styles
hs1 <- createStyle(fgFill = "#DCE6F1", halign = "CENTER", textDecoration = "Italic",
border = "Bottom", borderColour = "#4F81BD")
writeData(wb, "Cars", x, colNames = TRUE, rowNames = TRUE,
startCol="B", startRow = 23, borders="rows", headerStyle = hs1)
hs2 <- createStyle(fontColour = "#ffffff", fgFill = "#4F80BD",
halign = "center", valign = "center", textDecoration = "Bold",
border = "TopBottomLeftRight", borderColour = "#4F81BD")
writeData(wb, "Cars", x, colNames = TRUE, rowNames = TRUE,
startCol="O", startRow = 23, borders="columns", headerStyle = hs2)
## Save workbook
saveWorkbook(wb, "writeDataExample.xlsx", overwrite = TRUE)
Run the code above in your browser using DataLab