Class: Axlsx::ConditionalFormattingRule
- Inherits:
-
Object
- Object
- Axlsx::ConditionalFormattingRule
- Includes:
- OptionsParser, SerializedAttributes
- Defined in:
- lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb
Overview
The recommended way to manage these rules is via Worksheet#add_conditional_formatting
Conditional formatting rules specify formulas whose evaluations format cells
Instance Attribute Summary collapse
-
#aboveAverage ⇒ Boolean
Above average rule Indicates whether the rule is an "above average" rule.
-
#bottom ⇒ Boolean
Bottom N rule.
-
#dxfId ⇒ Integer
Differential Formatting Id.
-
#equalAverage ⇒ Boolean
Equal Average Flag indicating whether the 'aboveAverage' and 'belowAverage' criteria is inclusive of the average itself, or exclusive of that value.
-
#formula ⇒ String
Formula.
-
#operator ⇒ Symbol
Operator The operator in a "cell value is" conditional formatting rule.
-
#percent ⇒ Boolean
percent (Top 10 Percent) indicates whether a "top/bottom n" rule is a "top/bottom n percent" rule.
-
#priority ⇒ Integer
Priority The priority of this conditional formatting rule.
-
#rank ⇒ Integer
rank (Rank) The value of "n" in a "top/bottom n" conditional formatting rule.
-
#stdDev ⇒ Integer
stdDev (StdDev) The number of standard deviations to include above or below the average in the conditional formatting rule.
-
#stopIfTrue ⇒ Boolean
stopIfTrue (Stop If True) If this flag is '1', no rules with lower priority shall be applied over this rule, when this rule evaluates to true.
-
#text ⇒ String
Text used in a "text contains" conditional formatting rule.
-
#timePeriod ⇒ Object
timePeriod (Time Period) The applicable time period in a "date occurring…" conditional formatting rule.
-
#type ⇒ Symbol
Type (ST_CfType) options are expression, cellIs, colorScale, dataBar, iconSet, top10, uniqueValues, duplicateValues, containsText, notContainsText, beginsWith, endsWith, containsBlanks, notContainsBlanks, containsErrors, notContainsErrors, timePeriod, aboveAverage.
Instance Method Summary collapse
-
#color_scale ⇒ ColorScale
colorScale (Color Scale) The color scale to apply to this conditional formatting.
- #color_scale=(v) ⇒ Object
-
#data_bar ⇒ DataBar
dataBar (Data Bar) The data bar to apply to this conditional formatting.
- #data_bar=(v) ⇒ Object
-
#icon_set ⇒ IconSet
iconSet (Icon Set) The icon set to apply to this conditional formatting.
- #icon_set=(v) ⇒ Object
-
#initialize(options = {}) ⇒ ConditionalFormattingRule
constructor
Creates a new Conditional Formatting Rule object.
-
#to_xml_string(str = '') ⇒ String
Serializes the conditional formatting rule.
Methods included from SerializedAttributes
included, #serialized_attributes
Methods included from OptionsParser
Constructor Details
#initialize(options = {}) ⇒ ConditionalFormattingRule
Creates a new Conditional Formatting Rule object
29 30 31 32 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 29 def initialize(={}) @color_scale = @data_bar = @icon_set = @formula = nil end |
Instance Attribute Details
#aboveAverage ⇒ Boolean
Above average rule Indicates whether the rule is an "above average" rule. True indicates 'above average'. This attribute is ignored if type is not equal to aboveAverage.
56 57 58 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 56 def aboveAverage @aboveAverage end |
#bottom ⇒ Boolean
Bottom N rule
60 61 62 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 60 def bottom @bottom end |
#dxfId ⇒ Integer
Differential Formatting Id
64 65 66 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 64 def dxfId @dxfId end |
#equalAverage ⇒ Boolean
Equal Average Flag indicating whether the 'aboveAverage' and 'belowAverage' criteria is inclusive of the average itself, or exclusive of that value.
71 72 73 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 71 def equalAverage @equalAverage end |
#formula ⇒ String
Formula
40 41 42 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 40 def formula @formula end |
#operator ⇒ Symbol
Operator The operator in a "cell value is" conditional formatting rule. This attribute is ignored if type is not equal to cellIs
Operator must be one of lessThan, lessThanOrEqual, equal, notEqual, greaterThanOrEqual, greaterThan, between, notBetween, containsText, notContains, beginsWith, endsWith
81 82 83 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 81 def operator @operator end |
#percent ⇒ Boolean
percent (Top 10 Percent) indicates whether a "top/bottom n" rule is a "top/bottom n percent" rule. This attribute is ignored if type is not equal to top10.
102 103 104 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 102 def percent @percent end |
#priority ⇒ Integer
Priority The priority of this conditional formatting rule. This value is used to determine which format should be evaluated and rendered. Lower numeric values are higher priority than higher numeric values, where '1' is the highest priority.
89 90 91 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 89 def priority @priority end |
#rank ⇒ Integer
rank (Rank) The value of "n" in a "top/bottom n" conditional formatting rule. This attribute is ignored if type is not equal to top10.
108 109 110 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 108 def rank @rank end |
#stdDev ⇒ Integer
stdDev (StdDev) The number of standard deviations to include above or below the average in the conditional formatting rule. This attribute is ignored if type is not equal to aboveAverage. If a value is present for stdDev and the rule type = aboveAverage, then this rule is automatically an "above or below N standard deviations" rule.
118 119 120 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 118 def stdDev @stdDev end |
#stopIfTrue ⇒ Boolean
stopIfTrue (Stop If True) If this flag is '1', no rules with lower priority shall be applied over this rule, when this rule evaluates to true.
124 125 126 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 124 def stopIfTrue @stopIfTrue end |
#text ⇒ String
Text used in a "text contains" conditional formatting rule.
95 96 97 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 95 def text @text end |
#timePeriod ⇒ Object
timePeriod (Time Period) The applicable time period in a "date occurring…" conditional formatting rule. This attribute is ignored if type is not equal to timePeriod. Valid types are today, yesterday, tomorrow, last7Days, thisMonth, lastMonth, nextMonth, thisWeek, lastWeek, nextWeek
132 133 134 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 132 def timePeriod @timePeriod end |
#type ⇒ Symbol
Type (ST_CfType) options are expression, cellIs, colorScale, dataBar, iconSet, top10, uniqueValues, duplicateValues, containsText, notContainsText, beginsWith, endsWith, containsBlanks, notContainsBlanks, containsErrors, notContainsErrors, timePeriod, aboveAverage
49 50 51 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 49 def type @type end |
Instance Method Details
#color_scale ⇒ ColorScale
colorScale (Color Scale) The color scale to apply to this conditional formatting
138 139 140 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 138 def color_scale @color_scale ||= ColorScale.new end |
#color_scale=(v) ⇒ Object
186 187 188 189 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 186 def color_scale=(v) Axlsx::DataTypeValidator.validate 'conditional_formatting_rule.color_scale', ColorScale, v @color_scale = v end |
#data_bar ⇒ DataBar
dataBar (Data Bar) The data bar to apply to this conditional formatting
145 146 147 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 145 def @data_bar ||= DataBar.new end |
#data_bar=(v) ⇒ Object
192 193 194 195 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 192 def (v) Axlsx::DataTypeValidator.validate 'conditional_formatting_rule.data_bar', DataBar, v @data_bar = v end |
#icon_set ⇒ IconSet
iconSet (Icon Set) The icon set to apply to this conditional formatting
152 153 154 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 152 def icon_set @icon_set ||= IconSet.new end |
#icon_set=(v) ⇒ Object
198 199 200 201 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 198 def icon_set=(v) Axlsx::DataTypeValidator.validate 'conditional_formatting_rule.icon_set', IconSet, v @icon_set = v end |
#to_xml_string(str = '') ⇒ String
Serializes the conditional formatting rule
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 207 def to_xml_string(str = '') str << '<cfRule ' serialized_attributes str str << '>' str << '<formula>' << self.formula << '</formula>' if @formula @color_scale.to_xml_string(str) if @color_scale && @type == :colorScale @data_bar.to_xml_string(str) if @data_bar && @type == :dataBar @icon_set.to_xml_string(str) if @icon_set && @type == :iconSet str << '</cfRule>' end |