class RubyXL::WorkbookRelationships

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

Attributes

workbook[RW]

Public Class Methods

filepath() click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 59
def self.filepath
  File.join('xl', '_rels', 'workbook.xml.rels')
end

Public Instance Methods

before_write_xml() click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 30
def before_write_xml
  self.relationships = []

  @workbook.worksheets.each_with_index { |sheet, i|
    relationships << create_relationship(sheet.filepath.gsub(/^xl\//, ''), sheet.rel_type)
  }

  @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) click to toggle source
# 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) click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 55
def find_by_rid(r_id)
  relationships.find { |r| r.id == r_id }
end