personal-book/app/views/admin/books/download_excel.xlsx.axlsx

89 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

2016-06-04 07:41: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_book.book_title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_book.extracted_chapters") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_book.publisher") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_book.editor") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_book.authors") + " - " + t(locale.to_s)
end
row << t("personal_book.year")
row << t("personal_book.language")
row << t("personal_book.book_paper_type")
row << t("personal_book.pages")
row << t("personal_book.author_type")
row << t("personal_book.number_of_authors")
row << t("personal_book.publish_date")
row << t("personal_book.isbn")
row << t("personal_book.url")
row << t("personal_book.keywords")
row << t("personal_book.note")
sheet.add_row row, :style => heading
data.each do |book|
row = [book.member_profile.name]
@site_in_use_locales.each do |locale|
row << book.book_title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << book.extracted_chapters_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << book.publisher_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << book.editor_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << book.authors_translations[locale.to_s]
end
row << book.year
row << book.language
2016-06-06 09:14:39 +00:00
row << book.book_type.title rescue ""
2016-06-04 07:41:10 +00:00
row << book.pages
row << book.book_author_types.map{|bpt| bpt.title}.join(", ") rescue ""
row << book.number_of_authors
row << book.publish_date.strftime("%Y-%m-%d") rescue ""
row << book.isbn
row << book.url
row << book.keywords
row << book.note
sheet.add_row row
end
end
end