class Xlsxrb::Ooxml::Reader::ColumnsListener
SAX2 listener for parsing <cols><col> elements from worksheet XML.
Attributes
Returns { column_index => width } hash (1-based indices).
Returns { column_index => width } hash (1-based indices).
Public Class Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 2246 def initialize @raw_columns = {} @raw_column_attrs = {} end
Public Instance Methods
# File lib/xlsxrb/ooxml/reader.rb, line 2255 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