class Ecs::ImportStudentExcel < BaseImportExcel
  def read_each(&block)
    2.upto(sheet.last_row) do |row_num|
      data = sheet.row(row_num)

      number = data[0].to_s.strip
      name = data[1].to_s.strip
      next if number.blank?

      block.call(number, name)
    end
  end

  private

  def check_sheet_valid!
    raise_import_error('请按照模板格式导入') if sheet.cell(1, 1) != '学号（必填）' || sheet.cell(1, 2) != '姓名'
  end
end