3

I basically copied the example on DataValidation using openpyxl from the docs (https://openpyxl.readthedocs.io/en/stable/validation.html).

The only difference is that I set the showDropDown arg to True. Unfortunately, this doesn't make any difference, i.e. when I open the Excel sheet, I don't see the dropdown menu. In fact, it has not been enabled at all (compare screenshot).

from openpyxl import Workbook from openpyxl.worksheet.datavalidation import DataValidation # Create the workbook and worksheet we'll be working with wb = Workbook() ws = wb.active # Create a data-validation object with list validation dv = DataValidation( type="list", formula1='"Dog,Cat,Bat"', allow_blank=True, showDropDown=True ) # Optionally set a custom error message dv.error = "Your entry is not in the list" dv.errorTitle = "Invalid Entry" # Optionally set a custom prompt message dv.prompt = "Please select from the list" dv.promptTitle = "List Selection" # Add the data-validation object to the worksheet ws.add_data_validation(dv) dv.add(ws["A1"]) wb.save(filename="dropdown_issue.xlsx") 

enter image description here

1 Answer 1

12

Apparentyl, showDropDown is an alias for hide_drop_down. Setting showDropDown=False will do the trick.

This is confusing! An issue has already been opened some time ago at https://foss.heptapod.net/openpyxl/openpyxl/-/issues/1336.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.