personal-course/app/views/admin/courses/download_excel.xlsx.axlsx

39 lines
1.1 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_course.title") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_course.objective") + " - " + t(locale.to_s)
end
row << t("personal_course.year")
row << t("personal_course.course_semester")
row << t("personal_course.course_category")
sheet.add_row row, :style => heading
data.each do |course|
row = [course.member_profile.name]
@site_in_use_locales.each do |locale|
row << course.title_translations[locale.to_s]
end
@site_in_use_locales.each do |locale|
row << course.objective_translations[locale.to_s]
end
row << course.year
row << course.course_semester.title rescue ""
row << course.course_category.title rescue ""
sheet.add_row row
end
end
end