personal-activity/app/views/admin/activities/download_excel.xlsx.axlsx

55 lines
1.4 KiB
Plaintext

# encoding: utf-8
wb = xlsx_package.workbook
@data.each_with_index do |role,idx|
data = role["data"]
wb.add_worksheet(name: role["name"] + "-" + idx.to_s) do |sheet|
heading = sheet.styles.add_style(:b => true, :locked => true)
row = ["Name"]
@site_in_use_locales.each do |locale|
row << t("personal_activity.activity_name") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_activity.activity_organizer") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_activity.activity_area") + " - " + t(locale.to_s)
end
row << t("personal_activity.year")
row << t("personal_activity.activity_start_date")
row << t("personal_activity.activity_end_date")
row << t("personal_activity.note")
sheet.add_row row, :style => heading
data.each do |activity|
row = [activity.member_profile.name]
@site_in_use_locales.each do |locale|
row << activity.activity_name_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << activity.activity_organizer_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << activity.activity_area_translations[locale.to_s]
end
row << activity.year
row << activity.activity_start_date
row << activity.activity_end_date
row << activity.note
sheet.add_row row
end
end
end