Class: RubyXL::Writer::CoreWriter

Inherits:
GenericWriter show all
Defined in:
lib/rubyXL/writer/core_writer.rb

Instance Method Summary collapse

Methods inherited from GenericWriter

#add_to_zip, #initialize, #ooxml_object, #render_xml

Constructor Details

This class inherits a constructor from RubyXL::Writer::GenericWriter

Instance Method Details

#filepathObject



5
6
7
# File 'lib/rubyXL/writer/core_writer.rb', line 5

def filepath
  File.join('docProps', 'core.xml')
end

#writeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubyXL/writer/core_writer.rb', line 9

def write()
  render_xml do |xml|
    xml << (xml.create_element('cp:coreProperties', 
               'xmlns:cp' => 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
               'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
               'xmlns:dcterms' => 'http://purl.org/dc/terms/',
               'xmlns:dcmitype' => 'http://purl.org/dc/dcmitype/',
               'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') { |root|

      root << xml.create_element('dc:creator',        @workbook.creator)
      root << xml.create_element('cp:lastModifiedBy', @workbook.modifier)

      unless @workbook.created_at.to_s.empty?
        root << xml.create_element('dcterms:created',  { 'xsi:type' => 'dcterms:W3CDTF' }, @workbook.created_at)
      end

      unless @workbook.modified_at.to_s.empty?
        root << xml.create_element('dcterms:modified', { 'xsi:type' => 'dcterms:W3CDTF' }, @workbook.modified_at)
      end
    })
  end
end