Class: Axlsx::FilterColumn
- Inherits:
-
Object
- Object
- Axlsx::FilterColumn
- Defined in:
- lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb
Overview
The filterColumn collection identifies a particular column in the AutoFilter range and specifies filter information that has been applied to this column. If a column in the AutoFilter range has no criteria specified, then there is no corresponding filterColumn collection expressed for that column.
Constant Summary collapse
- FILTERS =
Allowed filters
[:filters]
Instance Attribute Summary collapse
-
#col_id ⇒ Integer
Zero-based index indicating the AutoFilter column to which this filter information applies.
-
#filter ⇒ Object
readonly
The actual filter being dealt with here This could be any one of the allowed filter types.
Instance Method Summary collapse
-
#apply(row, offset) ⇒ Object
Apply the filters for this column filtered.
- #hidden_button ⇒ Boolean
- #hidden_button=(hidden) ⇒ Boolean
-
#initialize(col_id, filter_type, options = {}) {|@filter| ... } ⇒ FilterColumn
constructor
Creates a new FilterColumn object.
-
#show_button ⇒ Boolean
Flag indicating whether the filter button is visible.
-
#show_button=(show) ⇒ Boolean
Flag indicating whether the AutoFilter button is show.
-
#to_xml_string(str = '') ⇒ Object
Serialize the object to xml.
Constructor Details
#initialize(col_id, filter_type, options = {}) {|@filter| ... } ⇒ FilterColumn
This class yeilds its filter object as that is where the vast majority of processing will be done
Creates a new FilterColumn object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 18 def initialize(col_id, filter_type, = {}) RestrictionValidator.validate 'FilterColumn.filter', FILTERS, filter_type #Axlsx::validate_unsigned_int(col_id) self.col_id = col_id .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end @filter = Axlsx.const_get(Axlsx.camel(filter_type)).new() yield @filter if block_given? end |
Instance Attribute Details
#col_id ⇒ Integer
Zero-based index indicating the AutoFilter column to which this filter information applies.
31 32 33 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 31 def col_id @col_id end |
#filter ⇒ Object (readonly)
The actual filter being dealt with here This could be any one of the allowed filter types
35 36 37 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 35 def filter @filter end |
Instance Method Details
#apply(row, offset) ⇒ Object
Apply the filters for this column filtered.
64 65 66 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 64 def apply(row, offset) row.hidden = @filter.apply(row.cells[offset+col_id.to_i]) end |
#hidden_button ⇒ Boolean
47 48 49 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 47 def @hidden_button ||= false end |
#hidden_button=(hidden) ⇒ Boolean
69 70 71 72 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 69 def (hidden) Axlsx.validate_boolean hidden @hidden_button = hidden end |
#show_button ⇒ Boolean
Flag indicating whether the filter button is visible. When the cell containing the filter button is merged with another cell, the filter button can be hidden, and not drawn.
41 42 43 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 41 def @show_button ||= true end |
#show_button=(show) ⇒ Boolean
Flag indicating whether the AutoFilter button is show. This is undocumented in the spec, but exists in the schema file as an optional attribute.
79 80 81 82 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 79 def (show) Axlsx.validate_boolean show @show_botton = show end |
#to_xml_string(str = '') ⇒ Object
Serialize the object to xml
85 86 87 88 89 |
# File 'lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb', line 85 def to_xml_string(str='') str << "<filterColumn #{serialized_attributes}>" @filter.to_xml_string(str) str << "</filterColumn>" end |