# NOT RUN {
wb <- createWorkbook()
sheet <- createSheet(wb, sheetName="CellBlock")
cb <- CellBlock(sheet, 7, 3, 1000, 60)
CB.setColData(cb, 1:100, 1) # set a column
CB.setRowData(cb, 1:50, 1) # set a row
# add a matrix, and style it
cs <- CellStyle(wb) + DataFormat("#,##0.00")
x <- matrix(rnorm(900*45), nrow=900)
CB.setMatrixData(cb, x, 10, 4, cellStyle=cs)
# highlight the negative numbers in red
fill <- Fill(foregroundColor = "red", backgroundColor="red")
ind <- which(x < 0, arr.ind=TRUE)
CB.setFill(cb, fill, ind[,1]+9, ind[,2]+3) # note the indices offset
# set the border on the top row of the Cell Block
border <- Border(color="blue", position=c("TOP", "BOTTOM"),
pen=c("BORDER_THIN", "BORDER_THICK"))
CB.setBorder(cb, border, 1:1000, 1)
# Don't forget to save the workbook ...
# saveWorkbook(wb, file)
# }
Run the code above in your browser using DataLab