personal-project/app/views/admin/projects/download_excel.xlsx.axlsx

75 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2016-06-02 11:38:50 +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_project.project_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_project.job_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_project.participator") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_project.unit") + " - " + t(locale.to_s)
end
row << t("personal_project.year")
row << t("personal_project.language")
row << t("personal_project.project_category")
row << t("personal_project.start_date")
row << t("personal_project.end_date")
row << t("personal_project.url")
row << t("personal_project.keywords")
row << t("personal_project.abstract")
row << t("personal_project.note")
sheet.add_row row, :style => heading
data.each do |proj|
row = [proj.member_profile.name]
@site_in_use_locales.each do |locale|
row << proj.project_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.job_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.participator_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.unit_translations[locale.to_s]
end
row << proj.year
row << proj.language
2016-06-06 09:16:39 +00:00
row << (proj.project_type.title rescue "")
2016-06-02 11:38:50 +00:00
row << proj.start_date.strftime("%Y-%m-%d") rescue ""
row << proj.end_date.strftime("%Y-%m-%d") rescue ""
row << proj.url
row << proj.keywords
row << proj.abstract
row << proj.note
sheet.add_row row
end
end
end