Method: Axlsx::ConditionalFormatting#add_rules

Defined in:
lib/axlsx/workbook/worksheet/conditional_formatting.rb

#add_rules(rules) ⇒ Object

be already created Axlsx::ConditionalFormattingRule elements or hashes of options for automatic creation. If rules is a hash instead of an array, assume only one rule being added.

Examples:

This would apply formatting "1" to cells > 20, and formatting "2" to cells < 1

conditional_formatting.add_rules [
    { :type => :cellIs, :operator => :greaterThan, :formula => "20", :dxfId => 1, :priority=> 1 },
    { :type => :cellIs, :operator => :lessThan, :formula => "10", :dxfId => 2, :priority=> 2 } ]

See Also:



43
44
45
46
47
48
# File 'lib/axlsx/workbook/worksheet/conditional_formatting.rb', line 43

def add_rules(rules)
  rules = [rules] if rules.is_a? Hash
  rules.each do |rule|
    add_rule rule
  end
end