Class: RubyXL::WorkbookRelationships
- Inherits:
-
OOXMLTopLevelObject
- Object
- OOXMLObject
- OOXMLTopLevelObject
- RubyXL::WorkbookRelationships
- Defined in:
- lib/rubyXL/objects/relationships.rb
Overview
Instance Attribute Summary collapse
-
#workbook ⇒ Object
Returns the value of attribute workbook.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from OOXMLTopLevelObject
#add_to_zip, parse_file, set_namespaces
Methods inherited from OOXMLObject
define_attribute, define_child_node, define_element_name, #dup, #index_in_collection, #initialize, obtain_class_variable, parse, set_countable, #write_xml
Constructor Details
This class inherits a constructor from RubyXL::OOXMLObject
Instance Attribute Details
#workbook ⇒ Object
Returns the value of attribute workbook.
22 23 24 |
# File 'lib/rubyXL/objects/relationships.rb', line 22 def workbook @workbook end |
Class Method Details
.filepath ⇒ Object
59 60 61 |
# File 'lib/rubyXL/objects/relationships.rb', line 59 def self.filepath File.join('xl', '_rels', 'workbook.xml.rels') end |
Instance Method Details
#before_write_xml ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubyXL/objects/relationships.rb', line 30 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
24 25 26 27 28 |
# File 'lib/rubyXL/objects/relationships.rb', line 24 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
55 56 57 |
# File 'lib/rubyXL/objects/relationships.rb', line 55 def find_by_rid(r_id) relationships.find { |r| r.id == r_id } end |