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 }) 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], 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 sheet.merge_cells("A#{index}:A#{index + items_size}") sheet.merge_cells("B#{index}:B#{index + items_size}") index += items_size end sheet.column_widths [400, 400] end end