openxlsx
openxlsx copied to clipboard
dataValidation multiple cols pick not working properly
Expected Behavior
cols = c(5, 10, 15) should apply the drop down list to coulmns 5, 10, 15
Actual Behavior
cols = c(5, 10, 15) applied the drop down list to coulmns 5:15
Steps to Reproduce the Problem
library(openxlsx)
df <- bind_cols(iris, iris, iris)
# create workbook
wb <- createWorkbook()
# initialize worksheet
addWorksheet( wb = wb, sheetName = "Sheet1" )
# add df to Sheet1
writeData( wb = wb
, sheet = "Sheet1"
, x = df
)
## Add dropdown list
addWorksheet(wb, "comment values")
comment <- data.frame(comments = unique(iris$Species))
col_n <- which(str_detect(names(df), "Species"))
writeData(wb, sheet = "comment values", comment, startCol = 1)
dataValidation(wb, 1, cols = col_n, rows = 2:(nrow(df)+1),
type = "list", value = "'comment values'!$A$2:$A$4")
openXL( file = wb )
sessionInfo()
- Version of openxlsx: 4.0.29 & 4.1.5
- Version of R: 3.6.1
Could you please create this also at ycphs/openxlsx?
I am maintaining the active fork of the package.
Just did, thanks!