Class: RubyXL::Writer::AppWriter

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

Instance Method Summary collapse

Methods inherited from GenericWriter

#add_to_zip, #initialize, #render_xml

Constructor Details

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

Instance Method Details

#filepathObject



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

def filepath
  File.join('docProps', 'app.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rubyXL/writer/app_writer.rb', line 9

def write()
  render_xml do |xml|
    xml << (xml.create_element('Properties',
            :xmlns => 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties',
            'xmlns:vt' => 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes') { |root|

      root << xml.create_element('Application', @workbook.application) unless @workbook.application.to_s.empty?
      root << xml.create_element('DocSecurity', 0)
      root << xml.create_element('ScaleCrop', false)

      root << (xml.create_element('HeadingPairs') { |headings|
        headings << (xml.create_element('vt:vector', :baseType => 'variant', :size => 2) { |vc|
          vc << (xml.create_element('vt:variant',) { |v| 
            v << xml.create_element('vt:lpstr', 'Worksheets')
          })

          vc << (xml.create_element('vt:variant',) { |v|
            v << xml.create_element('vt:i4', @workbook.worksheets.size)
          })
        })
      })

      root << (xml.create_element('TitlesOfParts') { |titles|
        titles << (xml.create_element('vt:vector', :baseType => 'lpstr',
                     :size => @workbook.worksheets.size) { |v|
          @workbook.worksheets.each { |sheet|
            v << (xml.create_element('vt:lpstr', sheet.sheet_name))
          }
        })
      })

      root << xml.create_element('Company', @workbook.company) unless @workbook.company.to_s.empty?
      root << xml.create_element('LinksUpToDate', false)
      root << xml.create_element('SharedDoc', false)
      root << xml.create_element('HyperlinksChanged', false)
      root << xml.create_element('AppVersion', @workbook.appversion) unless @workbook.appversion.to_s.empty?
    })
  end
end