Hi All ,
I need help in creating dependent data validation in R while creating an excel 
workbook
So i have two columns one has country and other states . I have to create the 
excel workbook in such a way that when i select the one specific country , the 
corresponding states appear in the next column . Something similar to dependent 
input in shiny ,
Here is the code what i have written

wb <- createWorkbook()
addWorksheet(wb, "Input")
addWorksheet(wb, "list")

df = data.frame("Country"=c("India","US"))
df1=data.frame("IndiaStates"=c("tamilnadu","Andhra pradesh"))
df2=data.frame("USStates"=c("Texas","California"))

# Add drop-down values "
writeData(wb, sheet = "list", x = df, startCol = 1)
writeData(wb, sheet = "list", x = df1, startCol = 2)
writeData(wb, sheet = "list", x = df2, startCol = 3)
#Add drop-downs to the column
dataValidation(wb, "input", col = 1, rows = 2:5, type = "list", value =
                 "'db'!$A$2:$A$3")

dataValidation(wb, "input", col = 2, rows = 2:5, type = "list", value =
                 "'db'!$b$2:$b$3")

dataValidation(wb, "input", col = 3, rows = 2:5, type = "list", value =
                 "'db'!$c$2:$c$3")

saveWorkbook(wb, "dataValidationExample.xlsx", overwrite = TRUE)


The states should be in single column in exported excel workbook with dependent 
data validation


Thanks, and Regards

Manish Mukherjee



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to