Class: OoxmlParser::ConditionalFormattingRule

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb

Overview

Class for ‘cfRule` data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ ConditionalFormattingRule

Returns a new instance of ConditionalFormattingRule.



49
50
51
52
53
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 49

def initialize(parent: nil)
  @above_average = true
  @formulas = []
  super
end

Instance Attribute Details

#above_averageBoolean (readonly)

Returns Specifies whether rule highlights values above average.

Returns:

  • (Boolean)

    Specifies whether rule highlights values above average



29
30
31
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 29

def above_average
  @above_average
end

#bottomSymbol (readonly)

Returns Specifies whether top/bottom rule highlights bottom values.

Returns:

  • (Symbol)

    Specifies whether top/bottom rule highlights bottom values



23
24
25
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 23

def bottom
  @bottom
end

#color_scaleColorScale (readonly)

Returns color scale formatting.

Returns:



45
46
47
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 45

def color_scale
  @color_scale
end

#data_barDataBar (readonly)

Returns data bar formatting.

Returns:

  • (DataBar)

    data bar formatting



43
44
45
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 43

def data_bar
  @data_bar
end

#equal_averageBoolean (readonly)

Returns Specifies whether rule highlights values equal to average.

Returns:

  • (Boolean)

    Specifies whether rule highlights values equal to average



31
32
33
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 31

def equal_average
  @equal_average
end

#format_indexInteger (readonly)

Returns index of format.

Returns:

  • (Integer)

    index of format



17
18
19
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 17

def format_index
  @format_index
end

#formulasArray<Formula> (readonly)

Returns Formulas to determine condition.

Returns:

  • (Array<Formula>)

    Formulas to determine condition



39
40
41
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 39

def formulas
  @formulas
end

#icon_setIconSet (readonly)

Returns icon set formatting.

Returns:

  • (IconSet)

    icon set formatting



47
48
49
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 47

def icon_set
  @icon_set
end

#idString (readonly)

Returns ID of rule.

Returns:

  • (String)

    ID of rule



15
16
17
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 15

def id
  @id
end

#operatorSymbol (readonly)

Returns Relational operator in value rule.

Returns:

  • (Symbol)

    Relational operator in value rule



21
22
23
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 21

def operator
  @operator
end

#percentSymbol (readonly)

Returns Specifies whether percent is used in top/bottom rule.

Returns:

  • (Symbol)

    Specifies whether percent is used in top/bottom rule



25
26
27
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 25

def percent
  @percent
end

#priorityInteger (readonly)

Returns Specifies position on the list of rules.

Returns:

  • (Integer)

    Specifies position on the list of rules



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 13

def priority
  @priority
end

#rankInteger (readonly)

Returns Number of items in top/bottom rule.

Returns:

  • (Integer)

    Number of items in top/bottom rule



27
28
29
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 27

def rank
  @rank
end

#rule_formatDifferentialFormattingRecord (readonly)

Returns Format.

Returns:



41
42
43
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 41

def rule_format
  @rule_format
end

#standard_deviationInteger (readonly)

Returns Number of standard deviations in above/below average rule.

Returns:

  • (Integer)

    Number of standard deviations in above/below average rule



33
34
35
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 33

def standard_deviation
  @standard_deviation
end

#stop_if_trueSymbol (readonly)

Returns Specifies whether rules with lower priority should be applied over this rule.

Returns:

  • (Symbol)

    Specifies whether rules with lower priority should be applied over this rule



19
20
21
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 19

def stop_if_true
  @stop_if_true
end

#textString (readonly)

Returns Text value in text rule.

Returns:

  • (String)

    Text value in text rule



35
36
37
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 35

def text
  @text
end

#time_periodSymbol (readonly)

Returns Time period in date rule.

Returns:

  • (Symbol)

    Time period in date rule



37
38
39
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 37

def time_period
  @time_period
end

#typeSymbol (readonly)

Returns Type of rule.

Returns:

  • (Symbol)

    Type of rule



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 11

def type
  @type
end

Instance Method Details

#formatnil, DifferentialFormattingRecord

Returns format of rule.

Returns:



110
111
112
113
114
115
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 110

def format
  return @rule_format if @rule_format
  return nil unless @format_index

  root_object.style_sheet.differential_formatting_records[@format_index]
end

#parse(node) ⇒ ConditionalFormattingRule

Parse ConditionalFormattingRule data

Parameters:

  • node (Nokogiri::XML:Element)

    with ConditionalFormattingRule data

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 58

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'type'
      @type = value.value.to_sym
    when 'priority'
      @priority = value.value.to_i
    when 'id'
      @id = value.value.to_s
    when 'dxfId'
      @format_index = value.value.to_i
    when 'stopIfTrue'
      @stop_if_true = attribute_enabled?(value)
    when 'operator'
      @operator = value.value.to_sym
    when 'bottom'
      @bottom = attribute_enabled?(value)
    when 'percent'
      @percent = attribute_enabled?(value)
    when 'rank'
      @rank = value.value.to_i
    when 'aboveAverage'
      @above_average = attribute_enabled?(value)
    when 'equalAverage'
      @equal_average = attribute_enabled?(value)
    when 'stdDev'
      @standard_deviation = value.value.to_i
    when 'text'
      @text = value.text.to_s
    when 'timePeriod'
      @time_period = value.value.to_sym
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'f'
      @formulas << Formula.new(parent: self).parse(node_child)
    when 'dxf'
      @rule_format = DifferentialFormattingRecord.new(parent: self).parse(node_child)
    when 'dataBar'
      @data_bar = DataBar.new(parent: self).parse(node_child)
    when 'colorScale'
      @color_scale = ColorScale.new(parent: self).parse(node_child)
    when 'iconSet'
      @icon_set = IconSet.new(parent: self).parse(node_child)
    end
  end
  self
end