class OpenXml::Xlsx::Parts::SharedStrings

Attributes

strings[R]

Public Class Methods

new() click to toggle source
# File lib/openxml/xlsx/parts/shared_strings.rb, line 7
def initialize
  @strings = Hash.new { |hash, key| hash[key] = hash.length }
end

Public Instance Methods

reference_of(string) click to toggle source
# File lib/openxml/xlsx/parts/shared_strings.rb, line 11
def reference_of(string)
  strings[string]
end
to_xml() click to toggle source
# File lib/openxml/xlsx/parts/shared_strings.rb, line 15
def to_xml
  build_standalone_xml do |xml|
    xml.sst(xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", uniqueCount: strings.length) do
      strings.each do |string, i|
        xml.si { xml.t(string) }
      end
    end
  end
end