class Roo::Excelx::SharedStrings

Public Instance Methods

[](index) click to toggle source
# File lib/roo/excelx/shared_strings.rb, line 5
def [](index)
  to_a[index]
end
to_a() click to toggle source
# File lib/roo/excelx/shared_strings.rb, line 9
def to_a
  @array ||= extract_shared_strings
end

Private Instance Methods

extract_shared_strings() click to toggle source
# File lib/roo/excelx/shared_strings.rb, line 15
def extract_shared_strings
  if doc_exists?
    # read the shared strings xml document
    doc.xpath("/sst/si").map do |si|
      shared_string = ''
      si.children.each do |elem|
        case elem.name
          when 'r'
            elem.children.each do |r_elem|
              if r_elem.name == 't'
                shared_string << r_elem.content
              end
            end
          when 't'
            shared_string = elem.content
        end
      end
      shared_string
    end
  else
    []
  end
end