Class: RubyXL::Writer::StylesWriter
- Inherits:
-
GenericWriter
- Object
- GenericWriter
- RubyXL::Writer::StylesWriter
- Defined in:
- lib/rubyXL/writer/styles_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
#filepath ⇒ Object
5 6 7 |
# File 'lib/rubyXL/writer/styles_writer.rb', line 5 def filepath File.join('xl', 'styles.xml') end |
#write ⇒ Object
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 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rubyXL/writer/styles_writer.rb', line 9 def write() render_xml do |xml| xml << (xml.create_element('styleSheet', :xmlns => "http://schemas.openxmlformats.org/spreadsheetml/2006/main") { |root| unless @workbook.num_fmts.empty? root << (xml.create_element('numFmts', :count => @workbook.num_fmts.size) { |numfmts| @workbook.num_fmts.each { |numfmt| numfmts << numfmt.write_xml(xml) } }) end root << (xml.create_element('fonts', :count => @workbook.fonts.size) { |fonts| @workbook.fonts.each_with_index { |font, i| fonts << font.write_xml(xml) } }) root << (xml.create_element('fills', :count => @workbook.fills.size) { |fills| @workbook.fills.each_with_index { |fill, i| fills << fill.write_xml(xml) } }) root << (xml.create_element('borders', :count => @workbook.borders.size) { |borders| @workbook.borders.each_with_index { |border, i| borders << border.write_xml(xml) } }) root << (xml.create_element('cellStyleXfs', :count => @workbook.cell_style_xfs.count) { |cxfs| @workbook.cell_style_xfs.each { |xf| cxfs << xf.write_xml(xml) } }) root << (xml.create_element('cellXfs', :count => @workbook.cell_xfs.size) { |cxfs| @workbook.cell_xfs.each { |xf| cxfs << xf.write_xml(xml) } }) root << (xml.create_element('cellStyles', :count => @workbook.cell_styles.size) { |cell_styles| @workbook.cell_styles.each { |style| cell_styles << style.write_xml(xml) } }) root << xml.create_element('dxfs', :count => 0) root << xml.create_element('tableStyles', :count => 0, :defaultTableStyle => 'TableStyleMedium9') unless @workbook.colors.empty? root << (xml.create_element('colors') { |colors| @workbook.colors.each_pair { |color_type, color_array| colors << (xml.create_element(color_type) { |type| color_array.each { |color| type << color.write_xml(xml) } }) } }) end }) end end |