personal-honor/app/views/admin/honors/download_excel.xlsx.axlsx

49 lines
1.2 KiB
Plaintext
Raw Normal View History

2016-06-06 09:15:12 +00:00
# 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_honor.award_name") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_honor.awarding_unit") + " - " + t(locale.to_s)
end
row << t("personal_honor.year")
row << t("personal_honor.language")
row << t("personal_honor.honor_category")
row << t("personal_honor.url")
row << t("personal_honor.keywords")
row << t("personal_honor.note")
sheet.add_row row, :style => heading
data.each do |hon|
row = [hon.member_profile.name]
@site_in_use_locales.each do |locale|
row << hon.award_name_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << hon.awarding_unit_translations[locale.to_s]
end
row << hon.year
row << hon.language
row << hon.honor_type.title rescue ""
row << hon.url
row << hon.keywords
row << hon.note
sheet.add_row row
end
end
end