Class: RubyXL::WorkbookRelationships
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from OOXMLObject
#add_to_zip, define_attribute, define_child_node, define_element_name, #dup, #index_in_collection, #initialize, obtain_class_variable, parse, parse_file, set_countable, set_namespaces, #write_xml
Instance Attribute Details
#workbook ⇒ Object
Returns the value of attribute workbook.
18
19
20
|
# File 'lib/rubyXL/objects/relationships.rb', line 18
def workbook
@workbook
end
|
Class Method Details
.filepath ⇒ Object
55
56
57
|
# File 'lib/rubyXL/objects/relationships.rb', line 55
def self.filepath
File.join('xl', '_rels', 'workbook.xml.rels')
end
|
Instance Method Details
#before_write_xml ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rubyXL/objects/relationships.rb', line 26
def before_write_xml
self.relationships = []
@workbook.worksheets.each_index { |i|
relationships << create_relationship("worksheets/sheet#{i + 1}.xml", 'worksheet')
}
@workbook.external_links.each_key { |k|
relationships << create_relationship("externalLinks/#{k}", 'externalLink')
}
relationships << create_relationship('theme/theme1.xml', 'theme')
relationships << create_relationship('styles.xml', 'styles')
if @workbook.shared_strings_container && !@workbook.shared_strings_container.strings.empty? then
relationships << create_relationship('sharedStrings.xml', 'sharedStrings')
end
if @workbook.calculation_chain && !@workbook.calculation_chain.cells.empty? then
relationships << create_relationship('calcChain.xml', 'calcChain')
end
true
end
|
#create_relationship(target, type) ⇒ Object
20
21
22
23
24
|
# File 'lib/rubyXL/objects/relationships.rb', line 20
def create_relationship(target, type)
RubyXL::Relationship.new(:id => "rId#{relationships.size + 1}",
:type => "http://schemas.openxmlformats.org/officeDocument/2006/relationships/#{type}",
:target => target)
end
|
#find_by_rid(r_id) ⇒ Object
51
52
53
|
# File 'lib/rubyXL/objects/relationships.rb', line 51
def find_by_rid(r_id)
relationships.find { |r| r.id == r_id }
end
|