Example usage for org.apache.poi.ss.usermodel Row cellIterator

List of usage examples for org.apache.poi.ss.usermodel Row cellIterator

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Row cellIterator.

Prototype

Iterator<Cell> cellIterator();

Source Link

Usage

From source file:com.gsecs.GSECSFrame.java

private void importCourseMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importCourseMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {/*from   w  ww. ja  va 2s.  c  om*/
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<CourseBean> courseBeanList = new ArrayList<CourseBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    CourseBean courseBean = new CourseBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            courseBean.setCourseCode((String) getCellValue(nextCell));
                            break;
                        case 1:
                            courseBean.setCourseName((String) getCellValue(nextCell));
                            break;
                        case 2:
                            courseBean.setCourseDesc((String) getCellValue(nextCell));
                            break;
                        case 3:
                            courseBean.setCourseHours(Double.valueOf(getCellValue(nextCell).toString()));
                            break;
                        case 4:
                            courseBean.setCourseCap(Double.valueOf(getCellValue(nextCell).toString()));
                            break;
                        case 5:
                            courseBean.setOfferedFall((String) getCellValue(nextCell));
                            break;
                        case 6:
                            courseBean.setOfferedSpring((String) getCellValue(nextCell));
                            break;
                        case 7:
                            courseBean.setOfferedSummer((String) getCellValue(nextCell));
                            break;
                        case 8:
                            courseBean.setCoursePreReq((String) getCellValue(nextCell));
                            break;
                        case 9:
                            courseBean.setTeacher((String) getCellValue(nextCell));
                            break;
                        }

                    }
                    courseBeanList.add(courseBean);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            CourseModel model = new CourseModel();
            CourseJInternalFrame courseFrame = new CourseJInternalFrame();
            courseFrame.getCourseMsgLabel().setText("");
            courseFrame.getAddCourseButton().setVisible(true);
            courseFrame.getUpdateCourseButton().setVisible(false);
            courseFrame.getDeleteCourseButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (CourseBean courseBean : courseBeanList) {
                try {
                    model.addCourse(courseBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            courseFrame.loadDataIntoJTable();
            mainPanel.add(courseFrame);
            courseFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.gsecs.GSECSFrame.java

private void importDegreePlanMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importDegreePlanMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {//from  w  w w.j a va 2  s .  c  o  m
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<DegreePlanBean> degreePlanBeanList = new ArrayList<DegreePlanBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    DegreePlanBean degreePlan = new DegreePlanBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            degreePlan.setDegreeCode((String) getCellValue(nextCell));
                            break;
                        case 1:
                            degreePlan.setDeptTrack((String) getCellValue(nextCell));
                            break;
                        case 2:
                            degreePlan.setDescription((String) getCellValue(nextCell));
                            break;
                        case 3:
                            degreePlan.setHoursReq(Double.valueOf(getCellValue(nextCell).toString()));
                            break;
                        case 4:
                            degreePlan.setType((String) getCellValue(nextCell));
                            break;
                        case 5:
                            degreePlan.setCourses((String) getCellValue(nextCell));
                            break;
                        case 6:
                            degreePlan.setGradSchool((String) getCellValue(nextCell));
                            break;
                        case 7:
                            degreePlan.setForecast(Double.valueOf(getCellValue(nextCell).toString()));
                            break;

                        }

                    }
                    degreePlanBeanList.add(degreePlan);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            DegreePlanModel model = new DegreePlanModel();
            DegreeJInternalFrame degreeFrame = new DegreeJInternalFrame();
            degreeFrame.getDegreeMsgLabel().setText("");
            degreeFrame.getAddDegreeButton().setVisible(true);
            degreeFrame.getUpdateDegreeButton().setVisible(false);
            degreeFrame.getDeleteDegreeButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (DegreePlanBean degreePlanBean : degreePlanBeanList) {
                try {
                    model.addDegree(degreePlanBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            degreeFrame.loadDataIntoJTable();
            mainPanel.add(degreeFrame);
            degreeFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.gsecs.GSECSFrame.java

private void importStudentMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importStudentMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {/*  w  w  w  . j  a  v  a2  s  .c om*/
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<StudentBean> studentBeansList = new ArrayList<StudentBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    StudentBean studentBean = new StudentBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            studentBean.setStudentId(getCellValue(nextCell).toString().replace(".0", ""));
                            break;
                        case 1:
                            studentBean.setDegreeCode((String) getCellValue(nextCell));
                            break;
                        case 2:
                            studentBean.setGraduationDate((String) getCellValue(nextCell));
                            break;

                        }

                    }
                    studentBeansList.add(studentBean);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            StudentModel model = new StudentModel();
            StudentJInternalFrame studentFrame = new StudentJInternalFrame();
            studentFrame.getStudentMsgLabel().setText("");
            studentFrame.getAddStudentButton().setVisible(true);
            studentFrame.getUpdateStudentButton().setVisible(false);
            studentFrame.getDeleteStudentButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (StudentBean studentBean : studentBeansList) {
                try {
                    model.addStudent(studentBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            studentFrame.loadDataIntoJTable();
            mainPanel.add(studentFrame);
            studentFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.gsecs.GSECSFrame.java

private void importStudentCourseMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importStudentCourseMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {/*www.j  a v  a 2 s.co m*/
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<StudentCourseBean> studentCourseBeansList = new ArrayList<StudentCourseBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    StudentCourseBean studentBean = new StudentCourseBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            studentBean.setStudentId(getCellValue(nextCell).toString().replace(".0", ""));
                            break;
                        case 1:
                            studentBean.setCourseId((String) getCellValue(nextCell));
                            break;
                        case 2:
                            studentBean.setCourseDesc((String) getCellValue(nextCell));
                            break;
                        case 3:
                            studentBean.setTerm((String) getCellValue(nextCell));
                            break;
                        case 4:
                            studentBean.setGrade((String) getCellValue(nextCell));
                            break;

                        }

                    }
                    studentCourseBeansList.add(studentBean);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            StudentModel model = new StudentModel();
            StudentCourseJInternalFrame studentFrame = new StudentCourseJInternalFrame();
            studentFrame.getStudentMsgLabel().setText("");
            studentFrame.getAddStudentCourseButton().setVisible(true);
            studentFrame.getUpdateStudentCourseButton().setVisible(false);
            studentFrame.getDeleteStudentCourseButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (StudentCourseBean studentBean : studentCourseBeansList) {
                try {
                    model.addStudentCourse(studentBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            studentFrame.loadDataIntoJTable();
            mainPanel.add(studentFrame);
            studentFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.gsecs.GSECSFrame.java

private void importcourseSectionMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importcourseSectionMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {//from   ww w .j  av a  2s. co  m
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<CourseSectionBean> courseSectionBeansList = new ArrayList<CourseSectionBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    CourseSectionBean courseSectionBean = new CourseSectionBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            courseSectionBean
                                    .setSectionNumber(getCellValue(nextCell).toString().replace(".0", ""));
                            break;
                        case 1:
                            courseSectionBean.setCourse((String) getCellValue(nextCell));
                            break;
                        case 2:
                            courseSectionBean.setFaculty((String) getCellValue(nextCell));
                            break;

                        }

                    }
                    courseSectionBeansList.add(courseSectionBean);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            CourseSectionModel model = new CourseSectionModel();
            CourseSectionJInternalFrame courseSectionFrame = new CourseSectionJInternalFrame();
            courseSectionFrame.getCourseSectionMsgLabel().setText("");
            courseSectionFrame.getAddCourseSectionButton().setVisible(true);
            courseSectionFrame.getUpdateCourseSectionButton().setVisible(false);
            courseSectionFrame.getDeleteCourseSectionButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (CourseSectionBean courseSectionBean : courseSectionBeansList) {
                try {
                    model.addCourseSection(courseSectionBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            courseSectionFrame.loadDataIntoJTable();
            mainPanel.add(courseSectionFrame);
            courseSectionFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.gsecs.GSECSFrame.java

private void importSemesterMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSemesterMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {//from   www.  ja  va 2 s .  c om
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<SemesterBean> semesterBeansList = new ArrayList<SemesterBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    SemesterBean semesterBean = new SemesterBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            semesterBean.setSemester((String) getCellValue(nextCell));
                            break;
                        case 1:
                            String[] stringDate = getCellValue(nextCell).toString().split("/");
                            semesterBean
                                    .setStartDate(stringDate[0] + "/" + stringDate[1] + "/20" + stringDate[2]);
                            break;
                        case 2:
                            String[] stringDate2 = getCellValue(nextCell).toString().split("/");
                            semesterBean
                                    .setEndDate(stringDate2[0] + "/" + stringDate2[1] + "/20" + stringDate2[2]);
                            break;

                        }

                    }
                    semesterBeansList.add(semesterBean);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            SemesterModel model = new SemesterModel();
            SemesterJInternalFrame semesterFrame = new SemesterJInternalFrame();
            semesterFrame.getSemesterMsgLabel().setText("");
            semesterFrame.getAddSemesterButton().setVisible(true);
            semesterFrame.getUpdateSemesterButton().setVisible(false);
            semesterFrame.getDeleteSemesterButton().setVisible(false);
            //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (SemesterBean semesterBean : semesterBeansList) {
                try {
                    model.addSemester(semesterBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            semesterFrame.loadDataIntoJTable();
            mainPanel.add(semesterFrame);
            semesterFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.gsecs.GSECSFrame.java

private void ImportUsersMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ImportUsersMenuItemActionPerformed
    // TODO add your handling code here:

    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {/*w  w w  .ja v  a 2s.c o m*/
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<UserBean> userBeansList = new ArrayList<UserBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    UserBean userBean = new UserBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            userBean.setLoginId(getCellValue(nextCell).toString());
                            break;
                        case 1:
                            userBean.setPassword((String) getCellValue(nextCell));
                            break;
                        case 2:
                            userBean.setRole((String) getCellValue(nextCell));
                            break;

                        }

                    }
                    userBeansList.add(userBean);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            UserModel model = new UserModel();
            UserJInternalFrame userFrame = new UserJInternalFrame();
            userFrame.getUsersMsgLabel().setText("");
            userFrame.getUserRegister().setVisible(true);
            userFrame.getUserUpdateButton().setVisible(false);
            userFrame.getUserDeleteButton().setVisible(false);
            //userFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (UserBean userBean : userBeansList) {
                try {
                    model.registerUser(userBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            userFrame.loadDataIntoJTable();
            mainPanel.add(userFrame);
            userFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.gsecs.GSECSFrame.java

private void ImportRoomMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ImportRoomMenuItemActionPerformed
    // TODO add your handling code here:
    JFileChooser jf = new JFileChooser();
    jf.setDialogTitle("Please select a excel File to import");
    int result = jf.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        String filePath = jf.getSelectedFile().getAbsolutePath();

        try {/*w ww  .  j  a  v  a2s  . com*/
            FileInputStream fis = new FileInputStream(filePath);
            Workbook workbook = new XSSFWorkbook(fis);
            Sheet firstSheet = workbook.getSheetAt(0);
            Iterator<Row> iterator = firstSheet.iterator();
            List<RoomBean> roomBeansList = new ArrayList<RoomBean>();

            while (iterator.hasNext()) {
                Row nextRow = iterator.next();
                if (nextRow.getRowNum() != 0) {
                    Iterator<Cell> cellIterator = nextRow.cellIterator();
                    RoomBean roomBean = new RoomBean();

                    while (cellIterator.hasNext()) {
                        Cell nextCell = cellIterator.next();
                        int columnIndex = nextCell.getColumnIndex();

                        switch (columnIndex) {
                        case 0:
                            roomBean.setRoomNumber(getCellValue(nextCell).toString());
                            break;
                        case 1:
                            roomBean.setCourseCode((String) getCellValue(nextCell));
                            break;
                        case 2:
                            roomBean.setCapacity((String) getCellValue(nextCell));
                            break;

                        }

                    }
                    roomBeansList.add(roomBean);
                }

            }
            workbook.close();
            fis.close();

            mainPanel.removeAll();
            mainPanel.repaint();
            RoomModel model = new RoomModel();
            RoomJInternalFrame roomFrame = new RoomJInternalFrame();
            roomFrame.getRoomMsgLabel().setText("");
            roomFrame.getAddRoomButton().setVisible(true);
            roomFrame.getUpdateRoomButton().setVisible(false);
            roomFrame.getDeleteRoomButton().setVisible(false);
            //userFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools()));
            for (RoomBean roomBean : roomBeansList) {
                try {
                    model.addRoom(roomBean);
                } catch (Exception exp) {
                    System.out.println("Exception Raised....." + exp.getMessage());
                }
            }
            roomFrame.loadDataIntoJTable();
            mainPanel.add(roomFrame);
            roomFrame.setVisible(true);
        } catch (Exception exp) {
            JOptionPane.showMessageDialog(null, exp.getMessage());
        }

    }
}

From source file:com.hurence.logisland.processor.excel.ExcelExtract.java

License:Apache License

private List<String> extractFieldNamesFromRow(Row row) {
    return StreamUtils.asStream(row.cellIterator()).map(Cell::getStringCellValue)
            .map(s -> s.replaceAll("\\s+", "_")).collect(Collectors.toList());
}

From source file:com.hust.zsuper.DealWithPatent.ExcelToMySQL.java

License:Open Source License

private List<Entry<String, ExcelType>> extractTypes(Sheet sheet) {

    final ArrayList<Entry<String, ExcelType>> columns = new ArrayList<Entry<String, ExcelType>>();
    int rowCount = 0;
    for (final Row row : new IteratorWrapper<Row>(sheet.iterator())) {
        if (rowCount < 1) {
            int cellCount = 0;
            //First row - get column names
            final Iterator<Cell> cellIterator = row.cellIterator();
            for (final Cell cell : new IteratorWrapper<Cell>(cellIterator)) {
                final String columnName = Utils.cleanUp(cell.getStringCellValue());
                addColumnName(columns, cellCount, columnName, sheet);
                cellCount++;/*from w w  w . ja va 2s . co m*/
            }
        } else if (rowCount < 2) {
            int cellCount = 0;
            //Second row - work out column type based on these values
            final Iterator<Cell> cellIterator = row.cellIterator();
            for (final Cell cell : new IteratorWrapper<Cell>(cellIterator)) {
                Entry<String, ExcelType> type = columns.get(cellCount);
                if (type != null) {
                    type.setValue(Utils.excelTypeToMySql(cell));
                }
                cellCount++;
            }
        }
        rowCount++;
    }
    return columns;

}