class TableData::Presenters::Excel

Constants

Bold

Public Instance Methods

document() click to toggle source
# 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) click to toggle source
# File lib/tabledata/presenters/excel.rb, line 27
def string(options=nil)
  document.to_string
end
write(path, options=nil) click to toggle source
# File lib/tabledata/presenters/excel.rb, line 31
def write(path, options=nil)
  document.write(path)
end