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 The formula or value to match against (e.g. 5 with an operator of :greaterThan to specify cell_value > 5).
-
#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
#declared_attributes, included, #serialized_attributes, #serialized_element_attributes, #serialized_tag
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.
58 59 60 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 58 def aboveAverage @aboveAverage end |
#bottom ⇒ Boolean
Bottom N rule
62 63 64 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 62 def bottom @bottom end |
#dxfId ⇒ Integer
Differential Formatting Id
66 67 68 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 66 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.
73 74 75 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 73 def equalAverage @equalAverage end |
#formula ⇒ String
Formula The formula or value to match against (e.g. 5 with an operator of :greaterThan to specify cell_value > 5). If the operator is :between or :notBetween, use an array to specify [minimum, maximum]
42 43 44 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 42 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
83 84 85 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 83 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.
104 105 106 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 104 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.
91 92 93 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 91 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.
110 111 112 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 110 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.
120 121 122 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 120 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.
126 127 128 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 126 def stopIfTrue @stopIfTrue end |
#text ⇒ String
Text used in a “text contains” conditional formatting rule.
97 98 99 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 97 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
134 135 136 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 134 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
51 52 53 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 51 def type @type end |
Instance Method Details
#color_scale ⇒ ColorScale
colorScale (Color Scale) The color scale to apply to this conditional formatting
140 141 142 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 140 def color_scale @color_scale ||= ColorScale.new end |
#color_scale=(v) ⇒ Object
188 189 190 191 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 188 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
147 148 149 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 147 def @data_bar ||= DataBar.new end |
#data_bar=(v) ⇒ Object
194 195 196 197 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 194 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
154 155 156 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 154 def icon_set @icon_set ||= IconSet.new end |
#icon_set=(v) ⇒ Object
200 201 202 203 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 200 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
209 210 211 212 213 214 215 216 217 218 |
# File 'lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb', line 209 def to_xml_string(str = '') str << '<cfRule ' serialized_attributes str str << '>' str << ('<formula>' << [*self.formula].join('</formula><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 |