class RubyXL::SharedStringsTable

www.schemacentral.com/sc/ooxml/e-ssml_sst.html

Public Class Methods

content_type() click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 55
def self.content_type
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
end
new(*params) click to toggle source
Calls superclass method
# File lib/rubyXL/objects/shared_strings.rb, line 17
def initialize(*params)
  super
  # So far, going by the structure that the original creator had in mind. However, 

  # since the actual implementation is now extracted into a separate class, 

  # we will be able to transparrently change it later if needs be.

  @index_by_content = {}
end
xlsx_path() click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 51
def self.xlsx_path
  File.join('xl', 'sharedStrings.xml')
end

Public Instance Methods

[](index) click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 31
def [](index)
  strings[index]
end
add(str, index = nil) click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 39
def add(str, index = nil)
  index ||= strings.size
  strings[index] = RubyXL::Text.new(:value => str)
  @index_by_content[str] = index
end
before_write_xml() click to toggle source
Calls superclass method
# File lib/rubyXL/objects/shared_strings.rb, line 25
def before_write_xml
  super
  self.unique_count = self.count
  self.count > 0
end
empty?() click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 35
def empty?
  strings.empty?
end
get_index(str, add_if_missing = false) click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 45
def get_index(str, add_if_missing = false)
  index = @index_by_content[str]
  index = add(str) if index.nil? && add_if_missing
  index 
end