Class: Defmastership::Export::XLSX::Formatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/defmastership/export/xlsx/formatter.rb

Overview

to export a XSLX file

Instance Attribute Summary

Attributes inherited from Formatter

#doc

Instance Method Summary collapse

Methods inherited from Formatter

#body, #header

Constructor Details

#initialize(doc, _options = {}) ⇒ Formatter

Returns a new instance of Formatter.

Parameters:

  • doc (Document)

    the document to export

  • _options (Hash{Symbol => Object}) (defaults to: {})


18
19
20
# File 'lib/defmastership/export/xlsx/formatter.rb', line 18

def initialize(doc, _options = {})
  super(doc)
end

Instance Method Details

#export_to(output_file) ⇒ Object

Export the document to a XSLX file

Parameters:

  • output_file (String)

    filename for the export



25
26
27
28
29
30
31
32
# File 'lib/defmastership/export/xlsx/formatter.rb', line 25

def export_to(output_file)
  workbook = RubyXL::Workbook.new
  column_list = build_column_list
  xlsx_data = XLSXData.new(self, workbook, doc, column_list)

  # Delegate the entire process to the XLSXData object
  xlsx_data.export_to(output_file, doc.definitions)
end