personal-experience/app/views/admin/experiences/download_excel.xlsx.axlsx

60 lines
1.7 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_experience.organizationt_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_experience.department") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_experience.job_title") + " - " + t(locale.to_s)
end
row << t("personal_experience.experience_category")
row << t("personal_experience.language")
row << t("personal_experience.start_date")
row << t("personal_experience.end_date")
row << t("personal_experience.url")
row << t("personal_experience.keywords")
row << t("personal_experience.note")
sheet.add_row row, :style => heading
data.each do |exp|
row = [exp.member_profile.name]
@site_in_use_locales.each do |locale|
row << exp.organizationt_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << exp.department_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << exp.job_title_translations[locale.to_s]
end
row << exp.experience_type.title rescue ""
row << exp.language
row << exp.start_date.strftime("%Y-%m-%d") rescue ""
row << exp.end_date.strftime("%Y-%m-%d") rescue ""
row << exp.url
row << exp.keywords
row << exp.note
sheet.add_row row
end
end
end