class OoxmlParser::ConditionalFormattingRule

Class for `cfRule` data

Attributes

above_average[R]

@return [Boolean] Specifies whether rule highlights values above average

bottom[R]

@return [Symbol] Specifies whether top/bottom rule highlights bottom values

color_scale[R]

@return [ColorScale] color scale formatting

data_bar[R]

@return [DataBar] data bar formatting

equal_average[R]

@return [Boolean] Specifies whether rule highlights values equal to average

format_index[R]

@return [Integer] index of format

formulas[R]

@return [Array<Formula>] Formulas to determine condition

icon_set[R]

@return [IconSet] icon set formatting

id[R]

@return [String] ID of rule

operator[R]

@return [Symbol] Relational operator in value rule

percent[R]

@return [Symbol] Specifies whether percent is used in top/bottom rule

priority[R]

@return [Integer] Specifies position on the list of rules

rank[R]

@return [Integer] Number of items in top/bottom rule

rule_format[R]

@return [DifferentialFormattingRecord] Format

standard_deviation[R]

@return [Integer] Number of standard deviations in above/below average rule

stop_if_true[R]

@return [Symbol] Specifies whether rules with lower priority should be applied over this rule

text[R]

@return [String] Text value in text rule

time_period[R]

@return [Symbol] Time period in date rule

type[R]

@return [Symbol] Type of rule

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/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

Public Instance Methods

format() click to toggle source

@return [nil, DifferentialFormattingRecord] format of rule

# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/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) click to toggle source

Parse ConditionalFormattingRule data @param [Nokogiri::XML:Element] node with ConditionalFormattingRule data @return [ConditionalFormattingRule] value of ConditionalFormattingRule data

# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/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