personal-patent/app/views/admin/patents/download_excel.xlsx.axlsx

65 lines
1.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_patent.patent_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_patent.patent_country") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_patent.authors") + " - " + t(locale.to_s)
end
row << t("personal_patent.year")
row << t("personal_patent.language")
row << t("personal_patent.patent_category")
row << t("personal_patent.patent_no")
row << t("personal_patent.publication_date")
row << t("personal_patent.url")
row << t("personal_patent.keywords")
row << t("personal_patent.note")
sheet.add_row row, :style => heading
data.each do |patent|
row = [(patent.member_profile_id.class == Array ? patent.member_profile_id.map{|member_id| MemberProfile.find(member_id).name rescue ""} : [patent.member_profile.name])]
@site_in_use_locales.each do |locale|
row << patent.patent_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << patent.patent_country_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << patent.authors_translations[locale.to_s]
end
row << patent.year
row << patent.language
row << patent.patent_types.map{|pt| pt.title}.join(", ") rescue ""
row << patent.patent_no
row << patent.publication_date.strftime("%Y-%m-%d") rescue ""
row << patent.url
row << patent.keywords
row << patent.note
sheet.add_row row
end
end
end