diff options
| author | Stephen Pike <[email protected]> | 2012-04-20 11:19:32 -0400 |
|---|---|---|
| committer | Stephen Pike <[email protected]> | 2012-04-20 15:09:50 -0400 |
| commit | 7ac97a793f7d2b20c23d455b3965a0af8bd5682b (patch) | |
| tree | 8aa7974900bace4824bb90fd73a11ffa4302d829 /lib/axlsx/workbook/worksheet/conditional_formatting.rb | |
| parent | 7ac3cd9ffb464f306520066dbfddd5c24ff29e9c (diff) | |
| download | caxlsx-7ac97a793f7d2b20c23d455b3965a0af8bd5682b.tar.gz caxlsx-7ac97a793f7d2b20c23d455b3965a0af8bd5682b.zip | |
Formatting and documentation cleanup
Diffstat (limited to 'lib/axlsx/workbook/worksheet/conditional_formatting.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/conditional_formatting.rb | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting.rb b/lib/axlsx/workbook/worksheet/conditional_formatting.rb index 01a1d719..13f6183d 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formatting.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formatting.rb @@ -3,22 +3,22 @@ module Axlsx # # @note The recommended way to manage conditional formatting is via Worksheet#add_conditional_formatting # @see Worksheet#add_conditional_formatting + # @see ConditionalFormattingRule class ConditionalFormatting - # Sqref - # Range over which the formatting is applied + # Range over which the formatting is applied, in "A1:B2" format # @return [String] attr_reader :sqref - # Rules # Rules to apply the formatting to. Can be either a hash of - # options for one ConditionalFormattingRule, an array of hashes + # options to create a {ConditionalFormattingRule}, an array of hashes # for multiple ConditionalFormattingRules, or an array of already # created ConditionalFormattingRules. + # @see ConditionalFormattingRule#initialize # @return [Array] attr_reader :rules - # Creates a new ConditionalFormatting object + # Creates a new {ConditionalFormatting} object # @option options [Array] rules The rules to apply # @option options [String] sqref The range to apply the rules to def initialize(options={}) @@ -28,10 +28,17 @@ module Axlsx end end - # Add ConditionalFormattingRules to this object. Rules can either - # be already created objects or hashes of options for automatic - # creation. - # @option rules [Array, Hash] the rules apply, can be just one in hash form + # Add Conditional Formatting Rules to this object. Rules can either + # be already created {ConditionalFormattingRule} elements or + # hashes of options for automatic creation. If rules is a hash + # instead of an array, assume only one rule being added. + # + # @example 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 } ] + # + # @param [Array|Hash] rules the rules to apply, can be just one in hash form # @see ConditionalFormattingRule#initialize def add_rules(rules) rules = [rules] if rules.is_a? Hash @@ -41,8 +48,8 @@ module Axlsx end # Add a ConditionalFormattingRule. If a hash of options is passed - # in create a rule on the fly - # @option rule [ConditionalFormattingRule, Hash] A rule to create + # in create a rule on the fly. + # @param [ConditionalFormattingRule|Hash] rule A rule to use, or the options necessary to create one. # @see ConditionalFormattingRule#initialize def add_rule(rule) if rule.is_a? Axlsx::ConditionalFormattingRule @@ -58,6 +65,12 @@ module Axlsx def sqref=(v); Axlsx::validate_string(v); @sqref = v end # Serializes the conditional formatting element + # @example Conditional Formatting XML looks like: + # <conditionalFormatting sqref="E3:E9"> + # <cfRule type="cellIs" dxfId="0" priority="1" operator="greaterThan"> + # <formula>0.5</formula> + # </cfRule> + # </conditionalFormatting> # @param [String] str # @return [String] def to_xml_string(str = '') |
