Class: Axlsx::AutoFilter
- Inherits:
-
Object
- Object
- Axlsx::AutoFilter
- Defined in:
- lib/axlsx/workbook/worksheet/auto_filter.rb
Overview
This class represents an auto filter range in a worksheet
Instance Attribute Summary collapse
-
#range ⇒ String
The range the autofilter should be applied to.
-
#worksheet ⇒ Object
readonly
Returns the value of attribute worksheet.
Instance Method Summary collapse
-
#defined_name ⇒ String
the formula for the defined name required for this auto filter.
-
#initialize(worksheet) ⇒ AutoFilter
constructor
creates a new Autofilter object.
-
#to_xml_string(str = '') ⇒ String
serialize the object.
Constructor Details
#initialize(worksheet) ⇒ AutoFilter
creates a new Autofilter object
8 9 10 11 |
# File 'lib/axlsx/workbook/worksheet/auto_filter.rb', line 8 def initialize(worksheet) raise ArgumentError, 'you must provide a worksheet' unless worksheet.is_a?(Worksheet) @worksheet = worksheet end |
Instance Attribute Details
#range ⇒ String
The range the autofilter should be applied to. This should be a string like 'A1:B8'
18 19 20 |
# File 'lib/axlsx/workbook/worksheet/auto_filter.rb', line 18 def range @range end |
#worksheet ⇒ Object (readonly)
Returns the value of attribute worksheet.
13 14 15 |
# File 'lib/axlsx/workbook/worksheet/auto_filter.rb', line 13 def worksheet @worksheet end |
Instance Method Details
#defined_name ⇒ String
the formula for the defined name required for this auto filter
22 23 24 25 |
# File 'lib/axlsx/workbook/worksheet/auto_filter.rb', line 22 def defined_name return unless range Axlsx.cell_range(range.split(':').collect { |name| worksheet.name_to_cell(name)}) end |
#to_xml_string(str = '') ⇒ String
serialize the object
29 30 31 |
# File 'lib/axlsx/workbook/worksheet/auto_filter.rb', line 29 def to_xml_string(str='') str << "<autoFilter ref='#{range}'></autoFilter>" end |