Class: CSVPlusPlus::Writer::Excel

Inherits:
Writer
  • Object
show all
Extended by:
T::Sig
Includes:
FileBackerUpper
Defined in:
lib/csv_plus_plus/writer/excel.rb

Overview

A class that can output a Template to an Excel file

Instance Attribute Summary

Attributes inherited from Writer

#position

Instance Method Summary collapse

Methods included from FileBackerUpper

#backup_file

Constructor Details

#initialize(options, position) ⇒ Excel

Returns a new instance of Excel.

Parameters:



17
18
19
20
21
# File 'lib/csv_plus_plus/writer/excel.rb', line 17

def initialize(options, position)
  super(position)

  @options = options
end

Instance Method Details

#write(template) ⇒ Object

Write the template to an Excel file

Parameters:

  • template (Template)

    The template to write



27
28
29
30
31
32
33
# File 'lib/csv_plus_plus/writer/excel.rb', line 27

def write(template)
  ::CSVPlusPlus::Writer::RubyXLBuilder.new(
    options: @options,
    position: @position,
    rows: template.rows
  ).build_workbook.write(@options.output_filename)
end

#write_backupObject

Write a backup of the current spreadsheet.



37
38
39
# File 'lib/csv_plus_plus/writer/excel.rb', line 37

def write_backup
  backup_file(@options)
end