awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
363 stars 79 forks source link

warning message from dataValidation with type="list" #546

Open namarkus opened 1 year ago

namarkus commented 1 year ago

Hi there,

it's just a minor issue, but it is annoying, because it generates constantly warning messages while building excel-files that contain dataValidation

reproducible example

using the example from the dataValidation help page:

wb <- createWorkbook()
addWorksheet(wb, "Sheet 1")
addWorksheet(wb, "Sheet 2")

writeDataTable(wb, sheet = 1, x = iris[1:30, ])
writeData(wb, sheet = 2, x = sample(iris$Sepal.Length, 10))

dataValidation(wb, 1, col = 1, rows = 2:31, type = "list", value = "'Sheet 2'!$A$1:$A$10")

step dataValidation generates warning message:

Warning message: In sprintf("<x14:dataValidation type=\"list\" allowBlank=\"%s\" showInputMessage=\"%s\" showErrorMessage=\"%s\">", : one argument not used by format ''

solution

The origin of this issue is found in function wb$dataValidation_list() in line:

data_val <- sprintf("<x14:dataValidation type=\"list\" allowBlank=\"%s\" showInputMessage=\"%s\" showErrorMessage=\"%s\">", 
                    allowBlank, showInputMsg, showErrorMsg, sqref)

the "sqref" value is superfluous. The string in fmt-argument expects only 3 values.

sessionInfo()