openpyxl.worksheet.datavalidation module

class openpyxl.worksheet.datavalidation.DataValidation(type=None, formula1=None, formula2=None, showErrorMessage=False, showInputMessage=False, showDropDown=False, allowBlank=False, sqref=(), promptTitle=None, errorStyle=None, error=None, prompt=None, errorTitle=None, imeMode=None, operator=None, allow_blank=None)[source]

Bases: Serialisable

add(cell)[source]

Adds a cell or cell coordinate to this validator

allowBlank

Values must be of type <class ‘bool’>

allow_blank

Values must be of type <class ‘bool’>

cells

Values must be of type <class ‘openpyxl.worksheet.cell_range.MultiCellRange’>

error

Values must be of type <class ‘str’>

errorStyle

Value must be one of {‘information’, ‘stop’, ‘warning’}

errorTitle

Values must be of type <class ‘str’>

formula1

Values must be of type <class ‘str’>

formula2

Values must be of type <class ‘str’>

hide_drop_down

Values must be of type <class ‘bool’>

imeMode

Value must be one of {‘noControl’, ‘disabled’, ‘halfHangul’, ‘off’, ‘fullAlpha’, ‘fullHangul’, ‘fullKatakana’, ‘on’, ‘halfKatakana’, ‘hiragana’, ‘halfAlpha’}

operator

Value must be one of {‘notBetween’, ‘notEqual’, ‘lessThanOrEqual’, ‘greaterThanOrEqual’, ‘between’, ‘equal’, ‘lessThan’, ‘greaterThan’}

prompt

Values must be of type <class ‘str’>

promptTitle

Values must be of type <class ‘str’>

ranges

Values must be of type <class ‘openpyxl.worksheet.cell_range.MultiCellRange’>

showDropDown

Values must be of type <class ‘bool’>

showErrorMessage

Values must be of type <class ‘bool’>

showInputMessage

Values must be of type <class ‘bool’>

sqref

Values must be of type <class ‘openpyxl.worksheet.cell_range.MultiCellRange’>

tagname = 'dataValidation'
type

Value must be one of {‘time’, ‘date’, ‘textLength’, ‘whole’, ‘decimal’, ‘custom’, ‘list’}

validation_type

Value must be one of {‘time’, ‘date’, ‘textLength’, ‘whole’, ‘decimal’, ‘custom’, ‘list’}

class openpyxl.worksheet.datavalidation.DataValidationList(disablePrompts=None, xWindow=None, yWindow=None, count=None, dataValidation=())[source]

Bases: Serialisable

append(dv)[source]
property count
dataValidation

A sequence (list or tuple) that may only contain objects of the declared type

disablePrompts

Values must be of type <class ‘bool’>

tagname = 'dataValidations'
to_tree(tagname=None)[source]

Need to skip validations that have no cell ranges

xWindow

Values must be of type <class ‘int’>

yWindow

Values must be of type <class ‘int’>

openpyxl.worksheet.datavalidation.collapse_cell_addresses(cells, input_ranges=())[source]

Collapse a collection of cell co-ordinates down into an optimal range or collection of ranges.

E.g. Cells A1, A2, A3, B1, B2 and B3 should have the data-validation object applied, attempt to collapse down to a single range, A1:B3.

Currently only collapsing contiguous vertical ranges (i.e. above example results in A1:A3 B1:B3).

openpyxl.worksheet.datavalidation.expand_cell_ranges(range_string)[source]

Expand cell ranges to a sequence of addresses. Reverse of collapse_cell_addresses Eg. converts “A1:A2 B1:B2” to (A1, A2, B1, B2)