personal-research/app/views/admin/researchs/download_excel.xlsx.axlsx

66 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2016-06-03 10:38:10 +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_research.research_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_research.extracted_chapters") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_research.authors") + " - " + t(locale.to_s)
end
2016-06-06 09:17:11 +00:00
row << t("personal_research.research_category")
2016-06-03 10:38:10 +00:00
row << t("personal_research.year")
row << t("personal_research.language")
row << t("personal_research.publication_date")
row << t("personal_research.url")
row << t("personal_research.keywords")
row << t("personal_research.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])]
2016-06-03 10:38:10 +00:00
@site_in_use_locales.each do |locale|
row << proj.research_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.extracted_chapters_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << proj.authors_translations[locale.to_s]
end
2016-06-06 09:17:11 +00:00
row << proj.research_category.title rescue ""
2016-06-03 10:38:10 +00:00
row << proj.year
row << proj.language
row << proj.publication_date.strftime("%Y-%m-%d") rescue ""
row << proj.url
row << proj.keywords
row << proj.note
sheet.add_row row
end
end
end