personal-lab/app/views/admin/labs/download_excel.xlsx.axlsx

69 lines
1.9 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_lab.lab_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_lab.location") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_lab.participating_professor") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_lab.participating_student") + " - " + t(locale.to_s)
end
row << t("personal_lab.year")
row << t("personal_lab.extension_no")
row << t("personal_lab.research_direction")
row << t("personal_lab.facility")
row << t("personal_lab.url")
row << t("personal_lab.keywords")
row << t("personal_lab.note")
sheet.add_row row, :style => heading
data.each do |proj|
row = [(proj.member_profile_id.class == Array ? proj.member_profile_id.map{|member_id| MemberProfile.find(member_id).name rescue ""} : [proj.member_profile.name])]
@site_in_use_locales.each do |locale|
row << proj.lab_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.location_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.participating_professor_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.participating_student_translations[locale.to_s]
end
row << proj.year
row << proj.extension_no
row << (proj.research_direction rescue "")
row << proj.facility rescue ""
row << proj.url
row << proj.keywords
row << proj.note
sheet.add_row row
end
end
end