openxlsx
openxlsx copied to clipboard
Warning in `dataValidation(type = "list")`
dataValidation(type = "list")
generates warning warning because of redundant argument to sprintf
:
https://github.com/ycphs/openxlsx/blob/d8c8209a42b7ec58e0066ccba9ea8a748ad77f16/R/WorkbookClass.R#:~:text=data_val%20%3C%2D%20sprintf(%27%3Cx14,showInputMsg%2C%20showErrorMsg%2C%20sqref)
Instead of
data_val <- sprintf('<x14:dataValidation type="list" allowBlank="%s" showInputMessage="%s" showErrorMessage="%s">',
allowBlank, showInputMsg, showErrorMsg, sqref)
should be
data_val <- sprintf('<x14:dataValidation type="list" allowBlank="%s" showInputMessage="%s" showErrorMessage="%s">',
allowBlank, showInputMsg, showErrorMsg)
Adding reprex (extracted from example(dataValidation)
on openxlsx 4.2.5.1):
library(openxlsx)
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")
#> Warning in sprintf("<x14:dataValidation type=\"list\" allowBlank=\"%s\"
#> showInputMessage=\"%s\" showErrorMessage=\"%s\">", : one argument not used by
#> format '<x14:dataValidation type="list" allowBlank="%s" showInputMessage="%s"
#> showErrorMessage="%s">'
Created on 2022-06-15 by the reprex package (v2.0.1)
@JanMarvin I can confirm the warning message is gone in the current development branch (not sure if you want to be actively tagged, but since you asked if someone could test the changes in the dev branch, I thought you'd want to).
Thanks for testing, @deschen1! I understand the repo is basically no longer maintained, but it would be nice if someone would close this issue since it's solved.
Rest assured, this repository is still maintained. The last merge to development was just yesterday. We might not always be the fastest, but not actively developing and not being maintained are different things. People just have different things to do in life and some of us have to work for a living 😉 There will be new releases with bugfixes etc, just not at the moment.
not actively developing and not being maintained are different things
You're right, sorry for misspeaking. Great to know there are new releases on the horizon!
Is it possible to define formula1 in dataValidation when the type is list by giving a list of values rather than specifying a sheet range? Like
library(openxlsx) 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 = "'option1,option2")
When I try to do this, I get an error in the resulting excel file.
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.