class Xlsxrb::Ooxml::Reader::ColumnsListener
SAX2 listener for parsing <cols><col> elements from worksheet XML.
Attributes
raw_column_attrs
[R]
untyped
Returns { column_index => width } hash (1-based indices).
raw_columns
[R]
untyped
Returns { column_index => width } hash (1-based indices).
Public Class Methods
() → untyped
Source
# File lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb, line 648 def initialize @raw_columns = {} @raw_column_attrs = {} end
Public Instance Methods
() → untyped
Source
# File lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb, line 653 def columns @raw_columns end
(untyped _uri, untyped local_name, untyped qname, untyped attributes) → untyped
Source
# File lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb, line 657 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) return unless name == "col" min_val = attributes["min"]&.to_i max_val = attributes["max"]&.to_i width = attributes["width"]&.to_f return unless min_val && max_val (min_val..max_val).each do |i| @raw_columns[i] = width if width attrs = {} attrs[:hidden] = true if attributes["hidden"] == "1" attrs[:best_fit] = true if attributes["bestFit"] == "1" ol = attributes["outlineLevel"] attrs[:outline_level] = ol.to_i if ol && ol != "0" attrs[:collapsed] = true if attributes["collapsed"] == "1" s = attributes["style"] attrs[:style] = s.to_i if s && s != "0" attrs[:phonetic] = true if attributes["phonetic"] == "1" @raw_column_attrs[i] = attrs unless attrs.empty? end end