Class: RubyXL::SharedStringsTable
Overview
Constant Summary
collapse
- CONTENT_TYPE =
'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
- REL_TYPE =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings'
OOXMLTopLevelObject::ROOT, OOXMLTopLevelObject::SAVE_ORDER
Instance Attribute Summary
#root
Instance Method Summary
collapse
#add_to_zip, #file_index, parse_file, set_namespaces
#==, included, #index_in_collection, #write_xml
Constructor Details
Returns a new instance of SharedStringsTable.
20
21
22
23
24
25
26
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 20
def initialize(*params)
super
@index_by_content = {}
end
|
Instance Method Details
#[](index) ⇒ Object
34
35
36
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 34
def [](index)
strings[index]
end
|
#add(str, index = nil) ⇒ Object
42
43
44
45
46
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 42
def add(str, index = nil)
index ||= strings.size
strings[index] = RubyXL::Text.new(:value => str)
@index_by_content[str] = index
end
|
#before_write_xml ⇒ Object
28
29
30
31
32
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 28
def before_write_xml
super
self.unique_count = self.count
self.count > 0
end
|
#empty? ⇒ Boolean
38
39
40
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 38
def empty?
strings.empty?
end
|
#get_index(str, add_if_missing = false) ⇒ Object
48
49
50
51
52
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 48
def get_index(str, add_if_missing = false)
index = @index_by_content[str]
index = add(str) if index.nil? && add_if_missing
index
end
|
#xlsx_path ⇒ Object
54
55
56
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 54
def xlsx_path
ROOT.join('xl', 'sharedStrings.xml')
end
|