personal-conference/app/views/admin/writing_conferences/download_excel.xlsx.axlsx

100 lines
2.8 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_conference.paper_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_conference.conference_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_conference.location") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_conference.sponsor") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_conference.authors") + " - " + t(locale.to_s)
end
row << t("personal_conference.year")
row << t("personal_conference.language")
row << t("personal_conference.period_start_date")
row << t("personal_conference.period_end_date")
row << t("personal_conference.paper_level")
row << t("personal_conference.paper_type")
row << t("personal_conference.author_type")
row << t("personal_conference.number_of_authors")
row << t("personal_conference.isbn")
row << t("personal_conference.publication_date")
row << t("personal_conference.isi_number")
row << t("personal_conference.url")
row << t("personal_conference.keywords")
row << t("personal_conference.abstract")
row << t("personal_conference.note")
sheet.add_row row, :style => heading
data.each do |cp|
row = [cp.member_profile.name]
@site_in_use_locales.each do |locale|
row << cp.paper_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << cp.conference_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << cp.location_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << cp.sponsor_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << cp.authors_translations[locale.to_s]
end
row << cp.year
row << cp.language
row << cp.period_start_date.strftime("%Y-%m-%d") rescue ""
row << cp.period_end_date.strftime("%Y-%m-%d") rescue ""
row << (cp.conference_paper_levels.map{|jl| jl.title}.join(", ") rescue "")
row << (cp.conference_paper_type.title rescue "")
row << (cp.conference_author_types.map{|jl| jl.title}.join(", ") rescue "")
row << cp.number_of_authors
row << cp.isbn
row << cp.publication_date.strftime("%Y-%m-%d") rescue ""
row << cp.isi_number
row << cp.url
row << cp.keywords
row << cp.abstract
row << cp.note
sheet.add_row row
end
end
end