I am preparing a report that I will need to re-run on a more or less weekly basis. It needs to go to the client in Excel and I've been using the XLConnect package for R with great success but I've got one problem I can't seem to over come on my own.
Given the following code:
simple <- data.frame(a = c(1,2,3,,4,5), b = c(1,2,3,4,5))
library(XLConnect)
prcntg <- createCellStyle(wb)
setDataFormat(prcntg, format = "0.0")
wb <- loadWorkbook("foo.xlsx", create = FALSE)
sheet <- "bar"
createSheet(wb, sheet)
writeWorksheet(wb, simple, sheet = sheet)
rows <- 1:5
cols <- 1:2
setCellStyle(wb, sheet = sheet, row = rows, col = cols, cellstyle = prcntg)
I want the values to be printed as:
a | b
1.0 | 1.0
2.0 | 2.0
3.0 | 3.0
etc.
But, they are coming into the worksheet as:
a | b
1 | 1
2 | 2
3 | 3
etc.
How do I get the former and not the latter. Based on the documentation and the post I saw here: https://miraisolutions.wordpress.com/2011/08/31/xlconnect-a-platform-independent-interface-to-excel/
I feel like I am doing everything right, but obviously I'm not.