基本语法 跳出for 循环
for (int k =currentCell.getRowIndex();k>=2 ;k--){ if (xSheet.getRow(k).getCell(parentCellList).getStringCellValue()!=null && !xSheet.getRow(k).getCell(parentCellList).getStringCellValue().equals("") ){ //找到父级别cell String parentContent = xSheet.getRow(k).getCell(parentCellList).getStringCellValue().trim(); String sql2= "select HR_DEPARTMENT_NAME.DEPTNO from HR_DEPARTMENT ,HR_DEPARTMENT_NAME " +"WHERE HR_DEPARTMENT_NAME.DEPTNO = HR_DEPARTMENT.DEPTNO and HR_DEPARTMENT.cpny_id = 'I11' and HR_DEPARTMENT_NAME.Content = '"+parentContent+"'"; rs=stm.executeQuery(sql2); while(rs.next()){ parent_no = rs.getString(1); }
//记得及时跳出for 循环 break; } }