bus_booking/app/views/admin/bus_bookings/export.xlsx.axlsx

37 lines
900 B
Plaintext
Raw Normal View History

2016-06-23 11:23:18 +00:00
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "BusBookingDetails") do |sheet|
mainheading = sheet.styles.add_style(:b => true, :locked => true, :alignment=>{:horizontal => :center})
heading = sheet.styles.add_style(:b => true, :locked => true)
sheet.merge_cells "A1:E1"
row = []
row << t("bus_booking.booking_details_for") + " " + @bus.bus_route
sheet.add_row row, :style => mainheading
row = []
row << t("bus_booking.registered_date")
row << t("bus_booking.name")
row << t("bus_booking.email")
row << t("bus_booking.dorm_number")
row << t("bus_booking.department")
sheet.add_row row, :style => heading
@bus.bookings.each do |booking|
row = []
row << booking.created_at.strftime("%Y-%m-%d %H:%M")
row << booking.name
row << booking.email
row << booking.dorm_number
row << booking.department
sheet.add_row row
end
end