I am using axlsx gem for creating excel spreadsheets. In my case, spreadsheet is created for notes model. The spreadsheet uses three model attributes as columns: devise number, volume and date. Each date column represents volume of the devise. I want to make automatic addition of date columns when comes new data from notes table. Like that:
The current state of excel table looks like this:
And this is code which was written using axlsx:
wb = xlsx_package.workbook
wb.styles do |style|
date_cell = style.add_style(format_code: "yyyy-mm-dd hh:mm")
wb.add_worksheet(name: "Notes") do |sheet|
sheet.add_row ["Devise number", "Volume", "Date"]
@notes.each do |note|
sheet.add_row [note.devise.number, note.volume, note.created_at],
style: [nil,nil, date_cell]
end
end
end
So, how to make automatic addition of date columns to table? Thank you, guys.