class Xlsxrb::Ooxml::SharedStringsParser::EventListener
SAX listener for generating events from shared string table.
Public Class Methods
Source
# File lib/xlsxrb/ooxml/shared_strings_parser.rb, line 34 def initialize(part_name, &block) @part_name = part_name @block = block @in_si = false @in_t = false @current_text = +"" @index = 0 end
Public Instance Methods
Source
# File lib/xlsxrb/ooxml/shared_strings_parser.rb, line 69 def characters(text) @current_text << text if @in_si && @in_t end
# File lib/xlsxrb/ooxml/shared_strings_parser.rb, line 53 def end_element(_uri, localname, _qname) case localname when "si" @in_si = false frozen_str = @current_text.freeze @block.call(Event.new( type: :sst_item, args: [frozen_str], source: { part: @part_name, index: @index } )) @index += 1 when "t" @in_t = false end end
# File lib/xlsxrb/ooxml/shared_strings_parser.rb, line 43 def start_element(_uri, localname, _qname, _attrs) case localname when "si" @in_si = true @current_text = +"" when "t" @in_t = true end end