graduation_subitems = @graduation_subitems graduation_standards = @graduation_standards standards_size = graduation_standards.size support_map = @subitem_support_standards.group_by do |support| [support.ec_requirement_standard_id, support.ec_graduation_subitem_id] end 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: 18, height: 22, b: true) ec_year_style = style.add_style(sz: 10, height: 14) note_style = style.add_style(sz: 11, height: 14, color: 'FF5500') label_style = style.add_style(sz: 11, b: true, bg_color: '90EE90', alignment: { horizontal: :center }) content_style = style.add_style(sz: 11, height: 16, border: { style: :thin, color: '000000' }) wb.add_worksheet(:name => '毕业要求对通用标准的支撑') do |sheet| sheet.add_row '毕业要求 vs 通用标准矩阵', style: title_style sheet.merge_cells wb.rows.first.cells[(1..standards_size)] sheet.add_row [] sheet.add_row ['专业代码', major.code], 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 ['注:“√” 表示有对应关系'], style: note_style objectives = standards_size.times.map { |index| "标准#{index + 1}" } sheet.add_row objectives.unshift('毕业要求指标点\通用标准'), style: label_style graduation_subitems.each do |graduation| data = graduation_standards.map do |standard| support_map[[standard.id, graduation.id]].present? ? '√' : '' end data.unshift("指导点#{graduation.ec_graduation_requirement.position}-#{graduation.position}") sheet.add_row data, style: ([content_style] * standards_size).unshift(label_style) end end end