class ScenarioList(Serialisable): tagname = "scenarios" scenario = Sequence(expected_type=Scenario) current = Integer(allow_none=True) show = Integer(allow_none=True) sqref = Convertible(expected_type=MultiCellRange, allow_none=True) __elements__ = ('scenario', ) def __init__( self, scenario=(), current=None, show=None, sqref=None, ): self.scenario = scenario self.current = current self.show = show self.sqref = sqref def append(self, scenario): s = self.scenario s.append(scenario) self.scenario = s def __bool__(self): return bool(self.scenario) __nonzero__ = __bool__
class ConditionalFormatting(Serialisable): tagname = "conditionalFormatting" sqref = Convertible(expected_type=MultiCellRange) cells = Alias("sqref") pivot = Bool(allow_none=True) cfRule = Sequence(expected_type=Rule) rules = Alias("cfRule") def __init__(self, sqref=(), pivot=None, cfRule=(), extLst=None): self.sqref = sqref self.pivot = pivot self.cfRule = cfRule def __eq__(self, other): if not isinstance(other, self.__class__): return False return self.sqref == other.sqref def __hash__(self): return hash(str(self.sqref)) def __repr__(self): return "<{cls} {cells}>".format(cls=self.__class__.__name__, cells=self.sqref) def __contains__(self, coord): """ Check whether a certain cell is affected by the formatting """ return coord in self.sqref
class DataValidation(Serialisable): tagname = "dataValidation" sqref = Convertible(expected_type=MultiCellRange) cells = Alias("sqref") ranges = Alias("sqref") showErrorMessage = Bool() showDropDown = Bool(allow_none=True) hide_drop_down = Alias('showDropDown') showInputMessage = Bool() showErrorMessage = Bool() allowBlank = Bool() allow_blank = Alias('allowBlank') errorTitle = String(allow_none = True) error = String(allow_none = True) promptTitle = String(allow_none = True) prompt = String(allow_none = True) formula1 = NestedText(allow_none=True, expected_type=str) formula2 = NestedText(allow_none=True, expected_type=str) type = NoneSet(values=("whole", "decimal", "list", "date", "time", "textLength", "custom")) errorStyle = NoneSet(values=("stop", "warning", "information")) imeMode = NoneSet(values=("noControl", "off", "on", "disabled", "hiragana", "fullKatakana", "halfKatakana", "fullAlpha","halfAlpha", "fullHangul", "halfHangul")) operator = NoneSet(values=("between", "notBetween", "equal", "notEqual", "lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual")) validation_type = Alias('type') def __init__(self, type=None, formula1=None, formula2=None, showErrorMessage=True, showInputMessage=True, showDropDown=None, allowBlank=None, sqref=(), promptTitle=None, errorStyle=None, error=None, prompt=None, errorTitle=None, imeMode=None, operator=None, allow_blank=None, ): self.sqref = sqref self.showDropDown = showDropDown self.imeMode = imeMode self.operator = operator self.formula1 = formula1 self.formula2 = formula2 if allow_blank is not None: allowBlank = allow_blank self.allowBlank = allowBlank self.showErrorMessage = showErrorMessage self.showInputMessage = showInputMessage self.type = type self.promptTitle = promptTitle self.errorStyle = errorStyle self.error = error self.prompt = prompt self.errorTitle = errorTitle def add(self, cell): """Adds a cell or cell coordinate to this validator""" if hasattr(cell, "coordinate"): cell = cell.coordinate self.sqref += cell def __contains__(self, cell): if hasattr(cell, "coordinate"): cell = cell.coordinate return cell in self.sqref