Class: DataShift::ExcelGenerator
- Inherits:
-
GeneratorBase
- Object
- GeneratorBase
- DataShift::ExcelGenerator
- Includes:
- ExcelBase
- Defined in:
- lib/datashift/generators/excel_generator.rb
Instance Attribute Summary collapse
-
#excel ⇒ Object
Returns the value of attribute excel.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
Attributes included from ExcelBase
Attributes inherited from GeneratorBase
Instance Method Summary collapse
-
#generate(file_name, klass, options = {}) ⇒ Object
Create an Excel file template (header row) representing supplied Model file_name => Filename for generated template.
-
#initialize ⇒ ExcelGenerator
constructor
A new instance of ExcelGenerator.
Methods included from ExcelBase
#ar_to_xls, #ar_to_xls_cell, #ar_to_xls_row, #exportable?, max_columns, #open_excel, #parse_headers, #sanitize_sheet_name, #start_excel
Methods included from Logging
#logdir, #logdir=, #logger, #verbose
Methods inherited from GeneratorBase
Constructor Details
#initialize ⇒ ExcelGenerator
Returns a new instance of ExcelGenerator.
21 22 23 |
# File 'lib/datashift/generators/excel_generator.rb', line 21 def initialize super end |
Instance Attribute Details
#excel ⇒ Object
Returns the value of attribute excel.
18 19 20 |
# File 'lib/datashift/generators/excel_generator.rb', line 18 def excel @excel end |
#file_name ⇒ Object
Returns the value of attribute file_name.
19 20 21 |
# File 'lib/datashift/generators/excel_generator.rb', line 19 def file_name @file_name end |
Instance Method Details
#generate(file_name, klass, options = {}) ⇒ Object
Create an Excel file template (header row) representing supplied Model file_name => Filename for generated template
See DataShift::Exporters::Configuration for options
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/datashift/generators/excel_generator.rb', line 30 def generate(file_name, klass, = {}) @file_name = file_name start_excel(klass, ) @headers = Headers.klass_to_headers(klass) @excel.set_headers(@headers) logger.info("ExcelGenerator saving generated template #{@file_name}") # @excel.autosize if(options[:autosize]) @excel.write( @file_name ) end |