Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB.setFill() doesn't seem to work properly #178

Open
fciarniello opened this issue May 11, 2021 · 0 comments
Open

CB.setFill() doesn't seem to work properly #178

fciarniello opened this issue May 11, 2021 · 0 comments

Comments

@fciarniello
Copy link

Hi I'm approaching the package "xlsx" for R and I discovered that the function "CB.setFill()", to color the background, does not work as it is reported in the manual, where I read:
<CB.setFill(cellBlock, fill, rowIndex, colIndex):
"rowIndex" is a numeric vector specifiying the rows you want relative to the startRow>.

First of all it doesn't seem to work when I use a numeric vector, it only works with scalar number.
But even with a single value, for the backgroundColor, it prints only the default color "lightblue" in the fill object.
I tried the lapply to iterate and it goes smooth but dosen't change the color in any way.

My system is:
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.5
year 2021
month 03
day 31
svn rev 80133
language R
version.string R version 4.0.5 (2021-03-31)
nickname Shake and Throw

I show an example of code:
`
x <- as.data.frame(state.x77)
x$State <- row.names(x)
row.names(x) <- NULL
x <- x[,c(9,1:8)]
tot <- data.frame(State="Total", t(colSums(x[, -1])))
names(tot) <- names(x)
x <- rbind(x, tot)
rm(tot)

library(xlsx)
wb <- createWorkbook(type="xlsx")
sheet <- createSheet(wb, sheetName = "US State Facts")

addDataFrame(x, sheet, startRow=1, startColumn=1, row.names=F)

cb <- CellBlock(sheet, startRow=1, startColumn=1, noRows=nrow(x)+1, noColumns=ncol(x), create=F)
fill01 <- Fill(backgroundColor = "white")
fill02 <- Fill(backgroundColor = "red")
CB.setFill(cb, fill01, rowIndex=1, colIndex=1:ncol(x))
CB.setFill(cb, fill02, rowIndex=2, colIndex=1:ncol(x))
CB.setFill(cb, fill02, rowIndex=3:5, colIndex=1:ncol(x)) # It doesn't work with vector parameter

lapply(6:9, function(k){ CB.setFill(cb, fill01, rowIndex=k, colIndex=1:ncol(x)) } ) #even with lapply the color doesn't change!

saveWorkbook(wb, "r-xlsx-report-example.xlsx")
`

I don't know if it is a bug or there is something that I didn't understand!

Best regards,
Francesco

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant