openpyxl.worksheet.filters module

class openpyxl.worksheet.filters.AutoFilter(ref=None, filterColumn=(), sortState=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

add_filter_column(col_id, vals, blank=False)[source]

Add row filter for specified column.

Parameters:
  • col_id (int) – Zero-origin column id. 0 means first column.
  • vals (str[]) – Value list to show.
  • blank (bool) – Show rows that have blank cell if True (default=``False``)
add_sort_condition(ref, descending=False)[source]

Add sort condition for cpecified range of cells.

Parameters:
  • ref (string) – range of the cells (e.g. ‘A2:A150’)
  • descending (bool) – Descending sort order (default=``False``)
extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

filterColumn

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

ref
sortState

Values must be of type <class ‘openpyxl.worksheet.filters.SortState’>

tagname = 'autoFilter'
class openpyxl.worksheet.filters.ColorFilter(dxfId=None, cellColor=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cellColor

Values must be of type <class ‘bool’>

dxfId

Values must be of type <class ‘int’>

tagname = 'colorFilter'
class openpyxl.worksheet.filters.CustomFilter(operator=None, val=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

operator

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

tagname = 'customFilter'
val

Values must be of type <class ‘str’>

class openpyxl.worksheet.filters.CustomFilters(_and=None, customFilter=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

customFilter

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

tagname = 'customFilters'
class openpyxl.worksheet.filters.DateGroupItem(year=None, month=None, day=None, hour=None, minute=None, second=None, dateTimeGrouping=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

dateTimeGrouping

Value must be one of {‘year’, ‘hour’, ‘minute’, ‘day’, ‘second’, ‘month’}

day

Values must be of type <class ‘float’>

hour

Values must be of type <class ‘float’>

minute

Values must be of type <class ‘float’>

month

Values must be of type <class ‘float’>

second

Values must be of type <class ‘int’>

tagname = 'dateGroupItem'
year

Values must be of type <class ‘int’>

class openpyxl.worksheet.filters.DynamicFilter(type=None, val=None, valIso=None, maxVal=None, maxValIso=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

maxVal

Values must be of type <class ‘float’>

maxValIso

Values must be of type <class ‘datetime.datetime’>

tagname = 'dynamicFilter'
type

Value must be one of {‘lastWeek’, ‘M2’, ‘yearToDate’, ‘M7’, ‘nextMonth’, ‘M3’, ‘lastYear’, ‘thisQuarter’, ‘lastMonth’, ‘thisWeek’, ‘null’, ‘M12’, ‘M10’, ‘M4’, ‘aboveAverage’, ‘M5’, ‘Q1’, ‘lastQuarter’, ‘Q3’, ‘yesterday’, ‘nextYear’, ‘thisYear’, ‘M8’, ‘M9’, ‘M11’, ‘M6’, ‘nextQuarter’, ‘thisMonth’, ‘M1’, ‘nextWeek’, ‘today’, ‘belowAverage’, ‘tomorrow’, ‘Q4’, ‘Q2’}

val

Values must be of type <class ‘float’>

valIso

Values must be of type <class ‘datetime.datetime’>

class openpyxl.worksheet.filters.FilterColumn(colId=None, hiddenButton=None, showButton=None, filters=None, top10=None, customFilters=None, dynamicFilter=None, colorFilter=None, iconFilter=None, extLst=None, blank=None, vals=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

colId

Values must be of type <class ‘int’>

col_id

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptve name is desired (eg. “underline” for “u”)

colorFilter

Values must be of type <class ‘openpyxl.worksheet.filters.ColorFilter’>

customFilters

Values must be of type <class ‘openpyxl.worksheet.filters.CustomFilters’>

dynamicFilter

Values must be of type <class ‘openpyxl.worksheet.filters.DynamicFilter’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

filters

Values must be of type <class ‘openpyxl.worksheet.filters.Filters’>

hiddenButton

Values must be of type <class ‘bool’>

iconFilter

Values must be of type <class ‘openpyxl.worksheet.filters.IconFilter’>

showButton

Values must be of type <class ‘bool’>

tagname = 'filterColumn'
top10

Values must be of type <class ‘openpyxl.worksheet.filters.Top10’>

class openpyxl.worksheet.filters.Filters(blank=None, calendarType=None, filter=(), dateGroupItem=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

blank

Values must be of type <class ‘bool’>

calendarType

Value must be one of {‘hijri’, ‘gregorianMeFrench’, ‘hebrew’, ‘gregorianUs’, ‘gregorianArabic’, ‘taiwan’, ‘thai’, ‘korea’, ‘gregorianXlitEnglish’, ‘gregorian’, ‘japan’, ‘saka’, ‘gregorianXlitFrench’}

dateGroupItem

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

filter

A sequence of primitive types that are stored as a single attribute. “val” is the default attribute

tagname = 'filters'
class openpyxl.worksheet.filters.IconFilter(iconSet=None, iconId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

iconId

Values must be of type <class ‘int’>

iconSet

Value must be one of {‘5ArrowsGray’, ‘5Rating’, ‘3TrafficLights1’, ‘4Rating’, ‘5Arrows’, ‘3Signs’, ‘4Arrows’, ‘4RedToBlack’, ‘3ArrowsGray’, ‘5Quarters’, ‘4ArrowsGray’, ‘3TrafficLights2’, ‘4TrafficLights’, ‘3Flags’, ‘3Arrows’, ‘3Symbols’, ‘3Symbols2’}

tagname = 'iconFilter'
class openpyxl.worksheet.filters.SortCondition(ref=None, descending=None, sortBy=None, customList=None, dxfId=None, iconSet=None, iconId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

customList

Values must be of type <class ‘str’>

descending

Values must be of type <class ‘bool’>

dxfId

Values must be of type <class ‘int’>

iconId

Values must be of type <class ‘int’>

iconSet

Value must be one of {‘5ArrowsGray’, ‘5Rating’, ‘3TrafficLights1’, ‘4Rating’, ‘5Arrows’, ‘3Signs’, ‘4Arrows’, ‘4RedToBlack’, ‘3ArrowsGray’, ‘5Quarters’, ‘4ArrowsGray’, ‘3TrafficLights2’, ‘4TrafficLights’, ‘3Flags’, ‘3Arrows’, ‘3Symbols’, ‘3Symbols2’}

ref
sortBy

Value must be one of {‘icon’, ‘fontColor’, ‘value’, ‘cellColor’}

tagname = 'sortCondition'
class openpyxl.worksheet.filters.SortState(columnSort=None, caseSensitive=None, sortMethod=None, ref=None, sortCondition=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caseSensitive

Values must be of type <class ‘bool’>

columnSort

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

ref
sortCondition

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

sortMethod

Value must be one of {‘pinYin’, ‘stroke’}

tagname = 'sortState'
class openpyxl.worksheet.filters.Top10(top=None, percent=None, val=None, filterVal=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

filterVal

Values must be of type <class ‘float’>

percent

Values must be of type <class ‘bool’>

tagname = 'top10'
top

Values must be of type <class ‘bool’>

val

Values must be of type <class ‘float’>