wb = xlsx_package.workbook wb.add_worksheet(name: '用户运营统计') do |sheet| sheet.add_row %w(单位名称 省份 注册老师数量 注册学生数量 活跃用户 学习关卡数 完成关卡数 评测次数) @schools.each do |school| data = [ school.name, school.province, school.display_extra_data(:reg_teacher_count), school.display_extra_data(:reg_student_count), school.display_extra_data(:user_active_count), school.display_extra_data(:study_challenge_count), school.display_extra_data(:finish_challenge_count), school.display_extra_data(:evaluate_count), ] sheet.add_row(data) end end