Trying to make simple changes to cells in a MS Excel sheet from Rvia XLConnect.
Specifically make the first row bold. What I see from quick search is that you can define a style within Excel and then import it to R but this option is not suitable for me since all the changes I make have to be reproducible by a R script.
Here is an example of an Excel file created with XLConnect:
require(XLConnect)
wb <- loadWorkbook("test.xlsx", create = TRUE)
createSheet(wb, name = "foo")
df <- data.frame(number = 1:4,
species = c("dog", "cat"))
writeWorksheet(wb, df, sheet = "foo", startRow = 1, startCol = 1)
saveWorkbook(wb)
Perhaps this is easier] with the xlsx package? I already ran into technical problems with openxlsx.
EDIT: I know how to change background color of a cell and assume similar method can be used to change fonts to bold:
cs.tr <- createCellStyle(wb)
setFillForegroundColor(cs.tr, color = XLC$"COLOR.WHITE")
setCellStyle(wb, sheet = "foo", row = 1, col = 1:2,
cellstyle = cs.tr)