personal_technique/app/views/admin/techniques/download_excel.xlsx.axlsx

50 lines
1.7 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 = [t("personal_technique.member_profile")]
@site_in_use_locales.each do |locale|
row << t("personal_technique.title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_technique.newsletter") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_technique.authors") + " - " + t(locale.to_s)
end
row << t("personal_technique.issue_date")
row << t("personal_technique.vol_no")
row << t("personal_technique.isbn")
row << t("personal_technique.url")
row << t("personal_technique.keywords")
row << t("personal_technique.note")
row << t("personal_technique.technique_status.status")
sheet.add_row row, :style => heading
data.each do |technique|
row = [(technique.member_profile.name rescue "")]
@site_in_use_locales.each do |locale|
row << technique.title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << technique.newsletter_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << technique.authors_translations[locale.to_s]
end
row << technique.display_field("issue_date",true)
row << technique.display_field("vol_no",true)
row << technique.display_field("isbn",true)
row << technique.display_field("url",true)
row << technique.display_field("keywords",true)
row << technique.display_field("note",true)
row << (technique.technique_status.status rescue "")
sheet.add_row row
end
end
end