Class: Timely::Formats::Excel

Inherits:
Timely::Formatter show all
Defined in:
lib/timely/formats/excel.rb

Constant Summary collapse

CELL_FORMATS =
{
  title: Spreadsheet::Format.new(bold: true, size: 14),
  headings: Spreadsheet::Format.new(bold: true, size: 10, align: 'right'),
  values: Spreadsheet::Format.new(align: 'right')
}

Instance Attribute Summary collapse

Attributes inherited from Timely::Formatter

#options, #report

Instance Method Summary collapse

Methods inherited from Timely::Formatter

#to_s

Constructor Details

#initialize(report, options = {}) ⇒ Excel

Returns a new instance of Excel.



14
15
16
17
18
19
20
21
# File 'lib/timely/formats/excel.rb', line 14

def initialize(report, options={})
  super

  @path       = options[:path] || Tempfile.new('timely-excel').path
  @row_idx    = 0
  @workbook   = Spreadsheet::Workbook.new
  @worksheet  = create_worksheet
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



12
13
14
# File 'lib/timely/formats/excel.rb', line 12

def path
  @path
end

#workbookObject (readonly)

Returns the value of attribute workbook.



12
13
14
# File 'lib/timely/formats/excel.rb', line 12

def workbook
  @workbook
end

#worksheetObject (readonly)

Returns the value of attribute worksheet.



12
13
14
# File 'lib/timely/formats/excel.rb', line 12

def worksheet
  @worksheet
end

Instance Method Details

#outputObject



23
24
25
26
27
28
29
30
31
# File 'lib/timely/formats/excel.rb', line 23

def output
  write_title
  write_columns
  write_rows
  write_generated_at
  save_workbook

  path
end