Class: ExportTo::Exporter::Xls

Inherits:
Struct
  • Object
show all
Defined in:
lib/export_to/exporter/xls.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rowsObject

Returns the value of attribute rows

Returns:

  • (Object)

    the current value of rows



3
4
5
# File 'lib/export_to/exporter/xls.rb', line 3

def rows
  @rows
end

Instance Method Details

#to_xlsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/export_to/exporter/xls.rb', line 5

def to_xls
  book = Spreadsheet::Workbook.new
  sheet = book.create_worksheet

  rows.each! do |columns, model, x|
    sheet.row(x).concat(columns)
  end

  spreadsheet = StringIO.new
  book.write(spreadsheet)

  spreadsheet.string
end