You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/views/ecs/ec_graduation_requirements/index.xlsx.axlsx

46 lines
1.7 KiB

graduation_requirements = @graduation_requirements
ec_year = @_current_year
major = ec_year.ec_major_school.ec_major
wb = xlsx_package.workbook
wb.styles do |style|
title_style = style.add_style(sz: 16, height: 20, b: true)
ec_year_style = style.add_style(sz: 10, height: 14)
label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center, vertical: :center })
content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' })
wb.add_worksheet(:name => '毕业要求及指标点') do |sheet|
sheet.add_row ['毕业要求及指标点'], style: title_style
sheet.add_row []
sheet.add_row ['专业代码', major.code.to_s + ' '], style: ec_year_style
sheet.add_row ['专业名称', major.name], style: ec_year_style
sheet.add_row ['学年', "#{ec_year.year}学年"], style: ec_year_style
sheet.add_row []
sheet.add_row %w(毕业要求 分解指标项), style: label_style
index = 7
graduation_requirements.each do |requirement|
requirement_content = "#{requirement.position}. #{requirement.content}"
requirement.ec_graduation_subitems.each do |item|
item_content = "#{requirement.position}-#{item.position}. #{item.content}"
sheet.add_row [requirement_content, item_content], style: content_style
end
items_size = requirement.ec_graduation_subitems.size
if items_size.zero?
sheet.add_row [requirement_content, ''], style: content_style
else
sheet.merge_cells("A#{index + 1}:A#{index + items_size}")
end
index += items_size
end
sheet.column_widths 100, 100
end
end