personal-journal/app/views/admin/journal_papers/download_excel.xlsx.axlsx

91 lines
2.3 KiB
Plaintext
Raw Normal View History

2016-06-01 11:39:51 +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_journal.paper_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_journal.journal_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_journal.authors") + " - " + t(locale)
end
row << t("personal_journal.year")
row << t("personal_journal.language")
row << t("personal_journal.vol_no")
row << t("personal_journal.issue_no")
row << t("personal_journal.total_pages")
row << t("personal_journal.level_type")
row << t("personal_journal.paper_type")
row << t("personal_journal.author_type")
row << t("personal_journal.number_of_authors")
row << t("personal_journal.isbn")
row << t("personal_journal.publication_date")
row << t("personal_journal.url")
row << t("personal_journal.keywords")
row << t("personal_journal.abstract")
row << t("personal_journal.note")
row << t("personal_journal.associated_project")
sheet.add_row row, :style => heading
data.each do |jp|
row = [jp.member_profile.name]
@site_in_use_locales.each do |locale|
row << jp.paper_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << jp.journal_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << jp.authors_translations[locale.to_s]
end
row << jp.year
row << jp.language
row << jp.vol_no
row << jp.issue_no
row << jp.total_pages
row << (jp.journal_levels.map{|jl| jl.title}.join(", ") rescue "")
row << (jp.journal_paper_type.title rescue "")
row << (jp.journal_paper_author_types.map{|jl| jl.title}.join(", ") rescue "")
row << jp.number_of_authors
row << jp.isbn
row << jp.publication_date.strftime("%Y-%m-%d") rescue ""
row << jp.url
row << jp.keywords
row << jp.abstract
row << jp.note
row << jp.associated_project
sheet.add_row row
end
end
end