personal_certificate/app/views/admin/certificates/download_excel.xlsx.axlsx

38 lines
1.3 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 = [t("personal_certificate.member_profile")]
@site_in_use_locales.each do |locale|
row << t("personal_certificate.title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_certificate.issued_by") + " - " + t(locale.to_s)
end
row << t("personal_certificate.year")
row << t("personal_certificate.issue_date")
row << t("personal_certificate.expiration_date")
row << t("personal_certificate.certificate_category.certificate_type")
sheet.add_row row, :style => heading
data.each do |certificate|
row = [(certificate.member_profile.name rescue "")]
@site_in_use_locales.each do |locale|
row << certificate.title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << certificate.issued_by_translations[locale.to_s]
end
row << certificate.display_field("year",true)
row << certificate.display_field("issue_date",true)
row << certificate.display_field("expiration_date",true)
row << (certificate.certificate_category.certificate_type rescue "")
sheet.add_row row
end
end
end