Sha256: f02b0155ee65ca878b839203d77604ac216ba0e392e695354bcbef5f61cf9a2b

Contents?: true

Size: 401 Bytes

Versions: 5

Compression:

Stored size: 401 Bytes

Contents

module XlsxWriter
  class Autofilter < ::Struct.new(:sheet, :range)
    def to_xml
      %{<autoFilter ref="#{range}" />}
    end

    # Sheet1!$A$1:$B$1
    def defined_name
      "#{sheet.name}!#{dollar_range}"
    end

    def dollar_range
      a = /([A-Z]+)(\d+):([A-Z]+)(\d+)/.match(range).captures.map { |c| c.prepend '$' }
      [ a.first(2).join, a.last(2).join ].join(':')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xlsx_writer-0.3.2 lib/xlsx_writer/autofilter.rb
xlsx_writer-0.3.1 lib/xlsx_writer/autofilter.rb
xlsx_writer-0.3.0 lib/xlsx_writer/autofilter.rb
xlsx_writer-0.2.2 lib/xlsx_writer/autofilter.rb
xlsx_writer-0.2.1 lib/xlsx_writer/autofilter.rb