List of usage examples for org.apache.poi.ss.usermodel Cell getColumnIndex
int getColumnIndex();
From source file:com.gsecs.GSECSFrame.java
private void importSchoolDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importSchoolDataActionPerformed // 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 v a 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<SchoolBean> schoolBeanList = new ArrayList<SchoolBean>(); while (iterator.hasNext()) { Row nextRow = iterator.next(); if (nextRow.getRowNum() != 0) { Iterator<Cell> cellIterator = nextRow.cellIterator(); SchoolBean school = new SchoolBean(); while (cellIterator.hasNext()) { Cell nextCell = cellIterator.next(); int columnIndex = nextCell.getColumnIndex(); switch (columnIndex) { case 0: school.setSchoolAbbrv((String) getCellValue(nextCell)); break; case 1: school.setSchoolName((String) getCellValue(nextCell)); break; } } schoolBeanList.add(school); } } workbook.close(); fis.close(); mainPanel.removeAll(); mainPanel.repaint(); GradSchoolModel model = new GradSchoolModel(); GradSchoolJInternalFrame schoolFrame = new GradSchoolJInternalFrame(); schoolFrame.getSchoolMsgLabel().setText(""); schoolFrame.getAddSchoolButton().setVisible(true); schoolFrame.getUpdateSchoolButton().setVisible(false); schoolFrame.getDeleteSchoolButton().setVisible(false); //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools())); for (SchoolBean schoolBean : schoolBeanList) { try { model.addSchool(schoolBean); } catch (Exception exp) { System.out.println("Exception Raised....." + exp.getMessage()); } } schoolFrame.loadDataIntoJTable(); mainPanel.add(schoolFrame); schoolFrame.setVisible(true); } catch (Exception exp) { JOptionPane.showMessageDialog(null, exp.getMessage()); } } }
From source file:com.gsecs.GSECSFrame.java
private void facultyImportMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_facultyImportMenuItemActionPerformed // 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 . 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<FacultyBean> facultyBeanList = new ArrayList<FacultyBean>(); while (iterator.hasNext()) { Row nextRow = iterator.next(); if (nextRow.getRowNum() != 0) { Iterator<Cell> cellIterator = nextRow.cellIterator(); FacultyBean faculty = new FacultyBean(); while (cellIterator.hasNext()) { Cell nextCell = cellIterator.next(); int columnIndex = nextCell.getColumnIndex(); switch (columnIndex) { case 0: faculty.setLastName((String) getCellValue(nextCell)); break; case 1: faculty.setFirstName((String) getCellValue(nextCell)); break; case 2: faculty.setGradSchool((String) getCellValue(nextCell)); break; case 3: faculty.setDegree((String) getCellValue(nextCell)); break; case 4: faculty.setTitle((String) getCellValue(nextCell)); break; case 5: faculty.setDaysToTeach(getCellValue(nextCell).toString()); break; case 6: faculty.setMaxLoadFall(Double.valueOf(getCellValue(nextCell).toString())); break; case 7: faculty.setMaxLoadSpring(Double.valueOf(getCellValue(nextCell).toString())); break; case 8: faculty.setMaxLoadSummer(Double.valueOf(getCellValue(nextCell).toString())); break; } } facultyBeanList.add(faculty); } } workbook.close(); fis.close(); mainPanel.removeAll(); mainPanel.repaint(); FacultyModel model = new FacultyModel(); FacultyJInternalFrame facultyFrame = new FacultyJInternalFrame(); facultyFrame.getFacultyMsgLabel().setText(""); facultyFrame.getAddFacultyButton().setVisible(true); facultyFrame.getUpdateFacultyButton().setVisible(false); facultyFrame.getDeleteFacultyButton().setVisible(false); //schoolFrame.getSchoolDataTable().setModel(DbUtils.resultSetToTableModel( new GradSchoolModel().getAllSchools())); for (FacultyBean facultyBean : facultyBeanList) { try { model.addFaculty(facultyBean); } catch (Exception exp) { System.out.println("Exception Raised....." + exp.getMessage()); } } facultyFrame.loadDataIntoJTable(); mainPanel.add(facultyFrame); facultyFrame.setVisible(true); } catch (Exception exp) { JOptionPane.showMessageDialog(null, exp.getMessage()); } } }
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 ww w . jav 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<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 ww .j a va 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<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 ww . j a v a 2 s .com 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 {// w ww . j a v a2s. c om 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 w ww . j a v a2 s .com 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 w w w. j a v a2 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<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 {//from www . j a 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 {//from 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<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()); } } }