Class: Writexlsx::Package::ConditionalFormat
- Inherits:
-
Object
- Object
- Writexlsx::Package::ConditionalFormat
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/package/conditional_format.rb
Direct Known Subclasses
AboveAverageFormat, BlanksOrErrorsFormat, CellIsFormat, ColorScaleFormat, DataBarFormat, ExpressionFormat, TextOrWithFormat, TimePeriodFormat, Top10Format
Constant Summary
Constants included from Utility
Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #bar_color ⇒ Object
- #criteria ⇒ Object
- #direction ⇒ Object
- #format ⇒ Object
- #formula ⇒ Object
-
#initialize(worksheet, range, param) ⇒ ConditionalFormat
constructor
A new instance of ConditionalFormat.
- #max_color ⇒ Object
- #max_type ⇒ Object
- #max_value ⇒ Object
- #maximum ⇒ Object
- #mid_color ⇒ Object
- #mid_type ⇒ Object
- #mid_value ⇒ Object
- #min_color ⇒ Object
- #min_type ⇒ Object
- #min_value ⇒ Object
- #minimum ⇒ Object
- #priority ⇒ Object
-
#range_param_for_conditional_formatting(*args) ⇒ Object
:nodoc:.
- #type ⇒ Object
- #value ⇒ Object
- #write_cf_rule ⇒ Object
- #write_cf_rule_formula_tag(tag = formula) ⇒ Object
-
#write_cfvo(type, val) ⇒ Object
Write the <cfvo> element.
-
#write_formula_tag(data) ⇒ Object
:nodoc:.
Methods included from Utility
#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, delete_files, #ptrue?, #put_deprecate_message, #row_col_notation, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #write_color, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str
Constructor Details
#initialize(worksheet, range, param) ⇒ ConditionalFormat
Returns a new instance of ConditionalFormat.
39 40 41 42 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 39 def initialize(worksheet, range, param) @worksheet, @range, @param = worksheet, range, param @writer = @worksheet.writer end |
Instance Attribute Details
#range ⇒ Object (readonly)
Returns the value of attribute range.
37 38 39 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 37 def range @range end |
Class Method Details
.factory(worksheet, *args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 8 def self.factory(worksheet, *args) range, param = Package::ConditionalFormat.new(worksheet, nil, nil). range_param_for_conditional_formatting(*args) case param[:type] when 'cellIs' CellIsFormat.new(worksheet, range, param) when 'aboveAverage' AboveAverageFormat.new(worksheet, range, param) when 'top10' Top10Format.new(worksheet, range, param) when 'containsText', 'notContainsText', 'beginsWith', 'endsWith' TextOrWithFormat.new(worksheet, range, param) when 'timePeriod' TimePeriodFormat.new(worksheet, range, param) when 'containsBlanks', 'notContainsBlanks', 'containsErrors', 'notContainsErrors' BlanksOrErrorsFormat.new(worksheet, range, param) when 'colorScale' ColorScaleFormat.new(worksheet, range, param) when 'dataBar' DataBarFormat.new(worksheet, range, param) when 'expression' ExpressionFormat.new(worksheet, range, param) else # when 'duplicateValues', 'uniqueValues' ConditionalFormat.new(worksheet, range, param) end end |
Instance Method Details
#attributes ⇒ Object
66 67 68 69 70 71 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 66 def attributes attr = ['type' , type] attr << 'dxfId' << format if format attr << 'priority' << priority attr end |
#bar_color ⇒ Object
144 145 146 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 144 def @param[:bar_color] end |
#criteria ⇒ Object
85 86 87 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 85 def criteria @param[:criteria] end |
#direction ⇒ Object
101 102 103 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 101 def direction @param[:direction] end |
#format ⇒ Object
77 78 79 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 77 def format @param[:format] end |
#formula ⇒ Object
105 106 107 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 105 def formula @param[:formula] end |
#max_color ⇒ Object
140 141 142 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 140 def max_color @param[:max_color] end |
#max_type ⇒ Object
132 133 134 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 132 def max_type @param[:max_type] end |
#max_value ⇒ Object
136 137 138 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 136 def max_value @param[:max_value] end |
#maximum ⇒ Object
89 90 91 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 89 def maximum @param[:maximum] end |
#mid_color ⇒ Object
128 129 130 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 128 def mid_color @param[:mid_color] end |
#mid_type ⇒ Object
120 121 122 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 120 def mid_type @param[:mid_type] end |
#mid_value ⇒ Object
124 125 126 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 124 def mid_value @param[:mid_value] end |
#min_color ⇒ Object
116 117 118 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 116 def min_color @param[:min_color] end |
#min_type ⇒ Object
109 110 111 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 109 def min_type @param[:min_type] end |
#min_value ⇒ Object
112 113 114 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 112 def min_value @param[:min_value] end |
#minimum ⇒ Object
93 94 95 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 93 def minimum @param[:minimum] end |
#priority ⇒ Object
81 82 83 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 81 def priority @param[:priority] end |
#range_param_for_conditional_formatting(*args) ⇒ Object
:nodoc:
148 149 150 151 152 153 154 155 156 157 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 148 def range_param_for_conditional_formatting(*args) # :nodoc: range_start_cell_for_conditional_formatting(*args) param_for_conditional_formatting(*args) handling_of_text_criteria if @param[:type] == 'text' handling_of_time_period_criteria if @param[:type] == 'timePeriod' handling_of_blanks_error_types [@range, @param] end |
#type ⇒ Object
73 74 75 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 73 def type @param[:type] end |
#value ⇒ Object
97 98 99 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 97 def value @param[:value] end |
#write_cf_rule ⇒ Object
44 45 46 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 44 def write_cf_rule @writer.empty_tag('cfRule', attributes) end |
#write_cf_rule_formula_tag(tag = formula) ⇒ Object
48 49 50 51 52 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 48 def write_cf_rule_formula_tag(tag = formula) @writer.tag_elements('cfRule', attributes) do write_formula_tag(tag) end end |
#write_cfvo(type, val) ⇒ Object
Write the <cfvo> element.
62 63 64 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 62 def write_cfvo(type, val) @writer.empty_tag('cfvo', ['type', type, 'val', val]) end |
#write_formula_tag(data) ⇒ Object
:nodoc:
54 55 56 57 |
# File 'lib/write_xlsx/package/conditional_format.rb', line 54 def write_formula_tag(data) #:nodoc: data = data.sub(/^=/, '') if data.respond_to?(:sub) @writer.data_element('formula', data) end |