Class: RubyXL::Writer::WorkbookRelsWriter
- Inherits:
-
GenericWriter
- Object
- GenericWriter
- RubyXL::Writer::WorkbookRelsWriter
- Defined in:
- lib/rubyXL/writer/workbook_rels_writer.rb
Instance Method Summary collapse
- #filepath ⇒ Object
-
#write ⇒ Object
all attributes out of order.
Methods inherited from GenericWriter
#add_to_zip, #initialize, #render_xml
Constructor Details
This class inherits a constructor from RubyXL::Writer::GenericWriter
Instance Method Details
#filepath ⇒ Object
6 7 8 |
# File 'lib/rubyXL/writer/workbook_rels_writer.rb', line 6 def filepath File.join('xl', '_rels', 'workbook.xml.rels') end |
#write ⇒ Object
all attributes out of order
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubyXL/writer/workbook_rels_writer.rb', line 11 def write() rels = [] @workbook.worksheets.each_index { |i| rels << [ "worksheets/sheet#{i + 1}.xml", 'worksheet' ] } @workbook.external_links.each_key { |k| rels << [ "externalLinks/#{k}", 'externalLink' ] } rels << [ 'theme/theme1.xml', 'theme' ] rels << [ 'styles.xml', 'styles' ] rels << [ 'sharedStrings.xml', 'sharedStrings' ] unless @workbook.shared_strings.empty? render_xml do |xml| xml << (xml.create_element('Relationships', :xmlns => 'http://schemas.openxmlformats.org/package/2006/relationships') { |root| rels.each_with_index { |rel, i| root << xml.create_element('Relationship', { :Id => "rId#{i + 1}", :Type => "http://schemas.openxmlformats.org/officeDocument/2006/relationships/#{rel.last}", :Target => rel.first }) } }) end end |