Class: Writexlsx::Package::ConditionalFormat
- Inherits:
-
Object
- Object
- Writexlsx::Package::ConditionalFormat
show all
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/package/conditional_format.rb
Constant Summary
Constants included
from Utility
Utility::CHAR_WIDTHS, Utility::COL_MAX, Utility::PERL_TRUE_VALUES, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utility
#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #color, #convert_date_time, #convert_font_args, #dash_types, delete_files, #escape_url, #fill_properties, #float_to_str, #get_font_latin_attributes, #get_font_style_attributes, #get_image_properties, #layout_properties, #legend_properties, #line_fill_properties, #line_properties, #params_to_font, #pattern_properties, #pixels_to_points, #process_bmp, #process_gif, #process_jpg, #process_png, #process_workbook_options, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_a_body_pr, #write_a_def_rpr, #write_a_end_para_rpr, #write_a_lst_style, #write_a_p_formula, #write_a_p_pr_formula, #write_a_solid_fill, #write_a_srgb_clr, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_def_rpr_r_pr_common, #write_div, #write_fill, #write_font, #write_stroke, #write_tx_pr, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xl_string_pixel_width, #xml_str
Constructor Details
#initialize(worksheet, range, param) ⇒ ConditionalFormat
Returns a new instance of ConditionalFormat.
43
44
45
46
47
48
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 43
def initialize(worksheet, range, param)
@worksheet = worksheet
@range = range
@param = param
@writer = @worksheet.writer
end
|
Instance Attribute Details
#range ⇒ Object
Returns the value of attribute range.
41
42
43
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 41
def range
@range
end
|
Class Method Details
.factory(worksheet, *args) ⇒ Object
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
36
37
38
39
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 9
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)
when 'iconSet'
IconSetFormat.new(worksheet, range, param)
else ConditionalFormat.new(worksheet, range, param)
end
end
|
Instance Method Details
#attributes ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 77
def attributes
attr = []
attr << ['type', type]
attr << ['dxfId', format] if format
attr << ['priority', priority]
attr << ['stopIfTrue', 1] if stop_if_true
attr
end
|
#bar_axis_color ⇒ Object
186
187
188
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 186
def bar_axis_color
@param[:bar_axis_color]
end
|
#bar_axis_position ⇒ Object
182
183
184
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 182
def bar_axis_position
@param[:bar_axis_position]
end
|
#bar_border_color ⇒ Object
166
167
168
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 166
def bar_border_color
@param[:bar_border_color]
end
|
#bar_color ⇒ Object
162
163
164
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 162
def bar_color
@param[:bar_color]
end
|
#bar_negative_color ⇒ Object
170
171
172
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 170
def bar_negative_color
@param[:bar_negative_color]
end
|
#bar_negative_color_same ⇒ Object
174
175
176
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 174
def bar_negative_color_same
@param[:bar_negative_color_same]
end
|
#bar_no_border ⇒ Object
178
179
180
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 178
def bar_no_border
@param[:bar_no_border]
end
|
#bar_only ⇒ Object
210
211
212
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 210
def bar_only
@param[:bar_only]
end
|
#criteria ⇒ Object
102
103
104
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 102
def criteria
@param[:criteria]
end
|
#direction ⇒ Object
118
119
120
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 118
def direction
@param[:direction]
end
|
90
91
92
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 90
def format
@param[:format]
end
|
122
123
124
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 122
def formula
@param[:formula]
end
|
#icon_style ⇒ Object
190
191
192
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 190
def icon_style
@param[:icon_style]
end
|
#icons ⇒ Object
198
199
200
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 198
def icons
@param[:icons]
end
|
#icons_only ⇒ Object
202
203
204
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 202
def icons_only
@param[:icons_only]
end
|
#max_color ⇒ Object
158
159
160
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 158
def max_color
@param[:max_color]
end
|
#max_type ⇒ Object
150
151
152
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 150
def max_type
@param[:max_type]
end
|
#max_value ⇒ Object
154
155
156
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 154
def max_value
@param[:max_value]
end
|
#maximum ⇒ Object
106
107
108
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 106
def maximum
@param[:maximum]
end
|
#mid_color ⇒ Object
146
147
148
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 146
def mid_color
@param[:mid_color]
end
|
#mid_type ⇒ Object
138
139
140
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 138
def mid_type
@param[:mid_type]
end
|
#mid_value ⇒ Object
142
143
144
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 142
def mid_value
@param[:mid_value]
end
|
#min_color ⇒ Object
134
135
136
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 134
def min_color
@param[:min_color]
end
|
#min_type ⇒ Object
126
127
128
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 126
def min_type
@param[:min_type]
end
|
#min_value ⇒ Object
130
131
132
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 130
def min_value
@param[:min_value]
end
|
#minimum ⇒ Object
110
111
112
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 110
def minimum
@param[:minimum]
end
|
#priority ⇒ Object
94
95
96
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 94
def priority
@param[:priority]
end
|
214
215
216
217
218
219
220
221
222
223
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 214
def range_param_for_conditional_formatting(*args) 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
|
#reverse_icons ⇒ Object
206
207
208
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 206
def reverse_icons
@param[:reverse_icons]
end
|
#stop_if_true ⇒ Object
98
99
100
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 98
def stop_if_true
@param[:stop_if_true]
end
|
#total_icons ⇒ Object
194
195
196
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 194
def total_icons
@param[:total_icons]
end
|
#type ⇒ Object
86
87
88
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 86
def type
@param[:type]
end
|
#value ⇒ Object
114
115
116
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 114
def value
@param[:value]
end
|
#write_cf_rule ⇒ Object
50
51
52
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 50
def write_cf_rule
@writer.empty_tag('cfRule', attributes)
end
|
54
55
56
57
58
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 54
def write_cf_rule_formula_tag(tag = formula)
@writer.tag_elements('cfRule', attributes) do
write_formula_tag(tag)
end
end
|
#write_cfvo(type, value, criteria = nil) ⇒ Object
Write the <cfvo> element.
68
69
70
71
72
73
74
75
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 68
def write_cfvo(type, value, criteria = nil)
attributes = [['type', type]]
attributes << ['val', value] if value
attributes << ['gte', 0] if ptrue?(criteria)
@writer.empty_tag('cfvo', attributes)
end
|
60
61
62
63
|
# File 'lib/write_xlsx/package/conditional_format.rb', line 60
def write_formula_tag(data) data = data.sub(/^=/, '') if data.respond_to?(:sub)
@writer.data_element('formula', data)
end
|