Class: TableData::Presenters::Excel
Constant Summary
collapse
- Bold =
Spreadsheet::Format.new weight: :bold
Instance Attribute Summary
#table
Instance Method Summary
collapse
#initialize, present
Instance Method Details
#document ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/tabledata/presenters/excel.rb', line 13
def document
document = Spreadsheet::Workbook.new
sheet = document.create_worksheet(name: @options[:worksheet_name])
sheet.row(0).default_format = Bold if @options[:bold_headers]
@table.data.each_with_index do |row, row_nr|
row.each_with_index do |col, col_nr|
sheet[row_nr, col_nr] = col
end
end
document
end
|
#string(options = nil) ⇒ Object
27
28
29
|
# File 'lib/tabledata/presenters/excel.rb', line 27
def string(options=nil)
document.to_string
end
|
#write(path, options = nil) ⇒ Object
31
32
33
|
# File 'lib/tabledata/presenters/excel.rb', line 31
def write(path, options=nil)
document.write(path)
end
|