R/writelim.R

Defines functions writelim

writelim <- function(X){
wb <- createWorkbook()
sheet <- createSheet(wb, sheetName="LIMeco")
cs <- CellStyle(wb) + Alignment(h="ALIGN_CENTER")
cs2 <- CellStyle(wb) + Font(wb, isBold=TRUE)+ Alignment(h="ALIGN_CENTER")
addDataFrame(X, sheet, startRow=1, startColumn=1, row.names=F, rownamesStyle=cs1, colnamesStyle=cs2, colStyle=list("1"=cs,"2"=cs,"3"=cs,"4"=cs,"5"=cs,"6"=cs,"7"=cs,"8"=cs))
rowm1 <-  nrow(X)
cb <- CellBlock(sheet, 2, 8, rowm1, 1, create=T)
CB.setColData(cb, 8, 1)
CB.setRowData(cb, 2:rowm1, 1)
x <- as.matrix(X[,8])
CB.setMatrixData(cb, x, 1, 1)
fill <- Fill(foregroundColor = "red", backgroundColor="red")
fill1 <- Fill(foregroundColor = "orange", backgroundColor="orange")
fill2 <- Fill(foregroundColor = "yellow", backgroundColor="yellow")
fill3 <- Fill(foregroundColor = "green", backgroundColor="green")
fill4 <- Fill(foregroundColor = "blue", backgroundColor="blue")
ind <- which(x == "CATTIVO", arr.ind=TRUE)
ind1 <- which(x == "SCARSO", arr.ind=TRUE)
ind2 <- which(x == "SUFFICIENTE", arr.ind=TRUE)
ind3 <- which(x == "BUONO", arr.ind=TRUE)
ind4 <- which(x == "ELEVATO", arr.ind=TRUE)
CB.setFill(cb, fill, ind[,1], ind[,2])
CB.setFill(cb, fill1, ind1[,1], ind1[,2])
CB.setFill(cb, fill2, ind2[,1], ind2[,2])
CB.setFill(cb, fill3, ind3[,1], ind3[,2])
CB.setFill(cb, fill4, ind4[,1], ind4[,2])
saveWorkbook(wb, "LIMeco.xlsx")
}
alexology/WFDItalia documentation built on Feb. 21, 2020, 11:13 p.m.