List of usage examples for org.apache.poi.hssf.usermodel HSSFRow cellIterator
@Override
public Iterator<Cell> cellIterator()
From source file:fitlibrary.runner.SpreadsheetRunner.java
License:Open Source License
@SuppressWarnings("unchecked") private HSSFCell[] getCells(HSSFRow row) { int maxCell = row.getLastCellNum(); HSSFCell[] cells = new HSSFCell[maxCell]; for (int i = 0; i < cells.length; i++) cells[i] = null;//from w w w. j av a 2s. c o m for (Iterator<HSSFCell> r = row.cellIterator(); r.hasNext();) { HSSFCell cell = r.next(); short cellNo = cell.getCellNum(); cells[cellNo] = cell; } return cells; }
From source file:fr.ens.transcriptome.aozan.io.CasavaDesignXLSReader.java
License:Open Source License
@Override public CasavaDesign read() throws IOException { // create a POIFSFileSystem object to read the data final POIFSFileSystem fs = new POIFSFileSystem(this.is); // Create a workbook out of the input stream final HSSFWorkbook wb = new HSSFWorkbook(fs); // Get a reference to the worksheet final HSSFSheet sheet = wb.getSheetAt(0); // When we have a sheet object in hand we can iterator on // each sheet's rows and on each row's cells. final Iterator<Row> rows = sheet.rowIterator(); final List<String> fields = new ArrayList<>(); while (rows.hasNext()) { final HSSFRow row = (HSSFRow) rows.next(); final Iterator<Cell> cells = row.cellIterator(); while (cells.hasNext()) { final HSSFCell cell = (HSSFCell) cells.next(); while (fields.size() != cell.getColumnIndex()) { fields.add(""); }// w w w .j a va2s . co m // Convert cell value to String fields.add(parseCell(cell)); } // Parse the fields if (!isFieldsEmpty(fields)) { parseLine(fields); } fields.clear(); } this.is.close(); return getDesign(); }
From source file:gatebass.utils.exel.POIExcelReader.java
/** * 41 This method is used to display the Excel content to command line. 42 * * * @param xlsPath// w w w .j a v a 2 s .c o m */ @SuppressWarnings("unchecked") public void displayFromExcel(String xlsPath) { // end_row = 2242; InputStream inputStream = null; try { inputStream = new FileInputStream(xlsPath); } catch (FileNotFoundException e) { System.out.println("File not found in the specified path."); e.printStackTrace(); } POIFSFileSystem fileSystem = null; int dd = 0; try { fileSystem = new POIFSFileSystem(inputStream); HSSFWorkbook workBook = new HSSFWorkbook(fileSystem); HSSFSheet sheet = workBook.getSheetAt(0); Iterator rows = sheet.rowIterator(); List<Individuals> individualses = new ArrayList<>(); while (rows.hasNext()) { HSSFRow row = (HSSFRow) rows.next(); // if (row.getRowNum() >= end_row) { // break; // } if (row.getRowNum() <= start_row) { continue; } dd = row.getRowNum(); // if (row.getRowNum() == 0 // || row.getRowNum() < 195 || row.getRowNum() > 250 // ) { // continue; // } Individuals individuals = null; // display row number in the console. // System.out.println("Row No.: " + row.getRowNum()); // once get a row its time to iterate through cells. Iterator cells = row.cellIterator(); while (cells.hasNext()) { HSSFCell cell = (HSSFCell) cells.next(); // System.out.println("Cell No.: " + cell.getCellNum()); /* * Now we will get the cell type and display the values * accordingly. */ switch (cell.getCellNum()) { case 0: individuals = new Individuals(); // individuals = new Individuals(Integer.parseInt(cell.getRichStringCellValue().getString())); break; case 1: try { individuals.setCard_id(((long) cell.getNumericCellValue()) + ""); } catch (Exception e) { } try { individuals.setCard_id(cell.getRichStringCellValue().getString()); } catch (Exception e) { } break; // case 2: // if (!cell.getRichStringCellValue().getString().isEmpty()) { // } // break; case 3: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setFirst_name(cell.getRichStringCellValue().getString()); } break; case 4: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setLast_name(cell.getRichStringCellValue().getString()); } break; case 6: try { individuals.setNational_id(((long) cell.getNumericCellValue()) + ""); } catch (Exception e) { } try { individuals.setNational_id(cell.getRichStringCellValue().getString()); } catch (Exception e) { } break; case 10: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setFirst_name_ENG(cell.getRichStringCellValue().getString()); } break; case 16: try { individuals.setPostal_code(((long) cell.getNumericCellValue()) + ""); } catch (Exception e) { } try { individuals.setPostal_code(cell.getRichStringCellValue().getString()); } catch (Exception e) { } break; case 17: try { individuals.setId_number(((long) cell.getNumericCellValue()) + ""); } catch (Exception e) { } try { individuals.setId_number(cell.getRichStringCellValue().getString()); } catch (Exception e) { } break; case 18: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setBirth_day(databaseHelper.historyDao.getFirst("date", cell.getRichStringCellValue().getString().substring(2))); } break; case 19: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setFather_first_name(cell.getRichStringCellValue().getString()); } break; case 20: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setBirth_state(cell.getRichStringCellValue().getString()); } break; case 21: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setIssued(cell.getRichStringCellValue().getString()); } break; case 22: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setStreet_address(cell.getRichStringCellValue().getString()); } break; case 23: String ss = cell.getRichStringCellValue().getString(); individuals.setVeteran_status(BEDONE_KART); if (!ss.isEmpty()) { if (ss.contains("?")) { individuals.setVeteran_status(MOAF); } else if (ss.contains("")) { individuals.setVeteran_status(PAYAN_KHEDMAT); } } break; case 25: try { individuals.setMobile(((long) cell.getNumericCellValue()) + ""); } catch (Exception e) { } try { individuals.setMobile(cell.getRichStringCellValue().getString()); } catch (Exception e) { } break; case 26: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setAcademic_degree(cell.getRichStringCellValue().getString()); } break; case 27: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setField_of_study(cell.getRichStringCellValue().getString()); } break; case 28: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setReligion(cell.getRichStringCellValue().getString()); } break; case 34: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setHave_soe_pishine(true); } break; case 35: if (!cell.getRichStringCellValue().getString().isEmpty()) { individuals.setComments(cell.getRichStringCellValue().getString()); } break; } switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: { // cell type numeric. // System.out.println("Numeric value: " + cell.getNumericCellValue()); break; } case HSSFCell.CELL_TYPE_STRING: { // cell type string. HSSFRichTextString richTextString = cell.getRichStringCellValue(); // System.out.println("String value: " + richTextString.getString()); break; } default: { // types other than String and Numeric. // System.out.println("Type not supported."); break; } } } String split = FileSystems.getDefault().getSeparator(); individuals.setFilesPatch( "data" + split + "1394" + split + dd / 50 + split + individuals.getNational_id() + split); File imageFile = new File( "d://test//Images-Personal-Gatepass//" + individuals.getCard_id() + ".jpg"); if (imageFile.exists()) { individuals.setPicture_address(individuals.getNational_id() + "-pic"); copyImageFile(imageFile.getAbsolutePath(), server + individuals.getFilesPatch(), individuals.getPicture_address()); individuals.setPicture_address( individuals.getPicture_address() + getFileExtension(imageFile.getAbsolutePath())); } individualses.add(individuals); // databaseHelper.individualsDao.createOrUpdate(individuals, dd); } databaseHelper.individualsDao.insertList(individualses); } catch (Exception e) { e.printStackTrace(); } }
From source file:gatebass.utils.exel.POIExcelReader.java
@SuppressWarnings("unchecked") public void displayFromExcel2(String xlsPath) { InputStream inputStream = null; try {/*from ww w .j a va 2 s.c om*/ inputStream = new FileInputStream(xlsPath); } catch (FileNotFoundException e) { System.out.println("File not found in the specified path."); e.printStackTrace(); } POIFSFileSystem fileSystem = null; int dd = 0; try { fileSystem = new POIFSFileSystem(inputStream); HSSFWorkbook workBook = new HSSFWorkbook(fileSystem); HSSFSheet sheet = workBook.getSheetAt(0); Iterator rows = sheet.rowIterator(); List<Cars> carses = new ArrayList<>(); while (rows.hasNext()) { HSSFRow row = (HSSFRow) rows.next(); // if (row.getRowNum() >= end_row) { // break; // } if (row.getRowNum() <= start_row) { continue; } dd = row.getRowNum(); // if (row.getRowNum() == 0 // || row.getRowNum() < 195 || row.getRowNum() > 250 // ) { // continue; // } Cars cars = null; // display row number in the console. // System.out.println("Row No.: " + row.getRowNum()); // once get a row its time to iterate through cells. Iterator cells = row.cellIterator(); while (cells.hasNext()) { HSSFCell cell = (HSSFCell) cells.next(); // System.out.println("Cell No.: " + cell.getCellNum()); /* * Now we will get the cell type and display the values * accordingly. */ switch (cell.getCellNum()) { case 0: cars = new Cars(); // individuals = new Individuals(Integer.parseInt(cell.getRichStringCellValue().getString())); break; case 1: try { cars.setCard_id(((long) cell.getNumericCellValue()) + ""); } catch (Exception e) { } try { cars.setCard_id(cell.getRichStringCellValue().getString()); } catch (Exception e) { } cars.setShasi_number(cars.getCard_id()); break; // case 2: // if (!cell.getRichStringCellValue().getString().isEmpty()) { // } // break; case 3: if (!cell.getRichStringCellValue().getString().isEmpty()) { cars.setCar_name(cell.getRichStringCellValue().getString()); } break; // case 4: // if (!cell.getRichStringCellValue().getString().isEmpty()) { // cars.setLast_name(cell.getRichStringCellValue().getString()); // } // break; // case 5: // if (!cell.getRichStringCellValue().getString().isEmpty()) { // cars.set(cell.getRichStringCellValue().getString()); // } // break; case 13: if (!cell.getRichStringCellValue().getString().isEmpty()) { cars.setComments(cell.getRichStringCellValue().getString()); } break; } switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: { // cell type numeric. // System.out.println("Numeric value: " + cell.getNumericCellValue()); break; } case HSSFCell.CELL_TYPE_STRING: { // cell type string. HSSFRichTextString richTextString = cell.getRichStringCellValue(); // System.out.println("String value: " + richTextString.getString()); break; } default: { // types other than String and Numeric. // System.out.println("Type not supported."); break; } } } String split = FileSystems.getDefault().getSeparator(); cars.setFilesPatch( "data" + split + "1394" + split + dd / 50 + split + cars.getShasi_number() + "_c" + split); carses.add(cars); // databaseHelper.individualsDao.createOrUpdate(individuals, dd); } databaseHelper.carDao.insertList(carses); } catch (Exception e) { e.printStackTrace(); } }
From source file:in.igsa.upload.FileUploadAction.java
License:Apache License
public String upload() throws Exception { try {// w ww. jav a 2s . c om Map<String, Object> session = ActionContext.getContext().getSession(); List<String> regionNames = new ArrayList<String>(); List<String> modelNames = new ArrayList<String>(); List<String> unitNames = new ArrayList<String>(); List<String> variableNames = new ArrayList<String>(); String emailError = ""; regionNames = service.getRegionNames(); modelNames = service.getModelNames(); unitNames = service.getUnitNames(); variableNames = service.getVariableNames(); String dateTime; Date date = new Date(); dateTime = DateTime.getDateTime1(date); String filePath = servletRequest.getSession().getServletContext().getRealPath("/") + "/files/"; File theFile; parent = new ArrayList<FileUploadVo>(); rowHeader = new FileUploadVo(); System.out.println(" contentType : " + contentType); boolean row_header = true; if ("application/vnd.ms-excel".equalsIgnoreCase(contentType)) { try { theFile = new File(filePath, DateTime.getFileForUpload(date) + ".xls"); if (theFile.exists()) { System.out.println(" file esist "); } else { System.out.println(" null file"); } fileNameForUpload = DateTime.getFileForUpload(date) + ".xls"; FileUtils.copyFile(upload, theFile); FileInputStream file = new FileInputStream(theFile); //new File("\\files\\howtodoinjava_demo.xls")); //Create Workbook instance holding reference to .xls file HSSFWorkbook workbook = new HSSFWorkbook(file); //Get first/desired sheet from the workbook (.xls) HSSFSheet sheet = workbook.getSheetAt(0); //Iterate through each rows one by one Iterator<Row> rowIterator = sheet.iterator(); while (rowIterator.hasNext()) { HSSFRow row = (HSSFRow) rowIterator.next(); //For each row, iterate through all the columns Iterator<Cell> cellIterator = row.cellIterator(); child = new FileUploadVo(); yearVal = new ArrayList<String>(); year = new ArrayList<String>(); int i = 1; if (row_header) { while (cellIterator.hasNext()) { HSSFCell cell = (HSSFCell) cellIterator.next(); //Check the cell type and format accordingly if (i > 5) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: mapHeader.put(i + "", cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: mapHeader.put(i + "", cell.getStringCellValue()); break; } } i++; } row_header = false; } else { while (cellIterator.hasNext()) { HSSFCell cell = (HSSFCell) cellIterator.next(); //Check the cell type and format accordingly if (i == 1) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setModel(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setModel(cell.getStringCellValue()); break; } } else if (i == 2) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setScenario(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setScenario(cell.getStringCellValue()); break; } } else if (i == 3) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setRegion(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setRegion(cell.getStringCellValue()); break; } } else if (i == 4) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setVariable(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setVariable(cell.getStringCellValue()); break; } } else if (i == 5) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setUnit(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setUnit(cell.getStringCellValue()); break; } } else { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: yearVal.add(cell.getNumericCellValue() + ""); year.add(mapHeader.get(i + "").toString()); break; case Cell.CELL_TYPE_STRING: yearVal.add(cell.getStringCellValue() + ""); year.add(mapHeader.get(i + "").toString()); break; } } //parent.add(child); //child.setValue(value); i++; } child.setVal(yearVal); child.setYear(year); child.setDateTime(dateTime); child.setUploadedBy(session.get("user_id").toString()); child.setFilePath("files/" + fileNameForUpload); parent.add(child); } } file.close(); } catch (Exception e) { e.printStackTrace(); } service.deleteModelSceRegion(child); for (FileUploadVo aa : parent) { boolean flag = true; if (!modelNames.contains(aa.getModel())) { emailError = emailError + "ERROR : Model name <i>" + aa.getModel() + "</i> not in list of valid Model name. <br>"; flag = false; } if (!regionNames.contains(aa.getRegion())) { emailError = emailError + "ERROR : Region name <i>" + aa.getRegion() + "</i> not in list of valid Region name. <br>"; flag = false; } if (!variableNames.contains(aa.getVariable())) { emailError = emailError + "ERROR : Variable name <i>" + aa.getVariable() + "</i> not in list of valid Variable name. <br>"; flag = false; } if (!unitNames.contains(aa.getUnit())) { emailError = emailError + "ERROR : Unit name <i>" + aa.getUnit() + "</i> not in list of valid Unit name. <br>"; flag = false; } if (flag) service.insertFileUpload(aa); else emailError = emailError + "********************************************<br>"; } } else if ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) { try { theFile = new File(filePath, DateTime.getFileForUpload(date) + ".xlsx"); fileNameForUpload = DateTime.getFileForUpload(date) + ".xlsx"; FileUtils.copyFile(upload, theFile); FileInputStream file = new FileInputStream(theFile); //new File("\\files\\howtodoinjava_demo.xls")); //Create Workbook instance holding reference to .xlsx file XSSFWorkbook workbook = new XSSFWorkbook(file); //Get first/desired sheet from the workbook XSSFSheet sheet = workbook.getSheetAt(0); //Iterate through each rows one by one Iterator<Row> rowIterator = sheet.iterator(); while (rowIterator.hasNext()) { XSSFRow row = (XSSFRow) rowIterator.next(); //For each row, iterate through all the columns Iterator<Cell> cellIterator = row.cellIterator(); child = new FileUploadVo(); yearVal = new ArrayList<String>(); year = new ArrayList<String>(); int i = 1; if (row_header) { while (cellIterator.hasNext()) { XSSFCell cell = (XSSFCell) cellIterator.next(); //Check the cell type and format accordingly if (i > 5) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: mapHeader.put(i + "", cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: mapHeader.put(i + "", cell.getStringCellValue()); break; } } i++; } row_header = false; } else { while (cellIterator.hasNext()) { XSSFCell cell = (XSSFCell) cellIterator.next(); //Check the cell type and format accordingly if (i == 1) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setModel(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setModel(cell.getStringCellValue()); break; } } else if (i == 2) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setScenario(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setScenario(cell.getStringCellValue()); break; } } else if (i == 3) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setRegion(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setRegion(cell.getStringCellValue()); break; } } else if (i == 4) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setVariable(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setVariable(cell.getStringCellValue()); break; } } else if (i == 5) { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: child.setUnit(cell.getNumericCellValue() + ""); break; case Cell.CELL_TYPE_STRING: child.setUnit(cell.getStringCellValue()); break; } } else { switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: yearVal.add(cell.getNumericCellValue() + ""); year.add(mapHeader.get(i + "").toString()); break; case Cell.CELL_TYPE_STRING: yearVal.add(cell.getStringCellValue() + ""); year.add(mapHeader.get(i + "").toString()); break; } } //parent.add(child); //child.setValue(value); i++; } child.setVal(yearVal); child.setYear(year); child.setDateTime(dateTime); child.setUploadedBy(session.get("user_id").toString()); child.setFilePath("files/" + fileNameForUpload); parent.add(child); System.out.println("\n"); } } file.close(); } catch (Exception e) { e.printStackTrace(); } service.deleteModelSceRegion(child); for (FileUploadVo aa : parent) { boolean flag = true; if (!modelNames.contains(aa.getModel())) { emailError = emailError + "ERROR : Model name " + aa.getModel() + " not in list of valid Model name. <br>"; flag = false; } if (!regionNames.contains(aa.getRegion())) { emailError = emailError + "ERROR : Region name " + aa.getRegion() + " not in list of valid Region name. <br>"; flag = false; } if (!variableNames.contains(aa.getVariable())) { emailError = emailError + "ERROR : Variable name " + aa.getVariable() + " not in list of valid Variable name. <br>"; flag = false; } if (!unitNames.contains(aa.getUnit())) { emailError = emailError + "ERROR : Unit name " + aa.getUnit() + " not in list of valid Unit name. <br>"; flag = false; } if (flag) service.insertFileUpload(aa); else emailError = emailError + "********************************************<br>"; } } else { addActionError(" File Format Should be xls or xlsx "); scenarioReport = service.getScenarioReport(); return INPUT; } String subject = "Error : undefined parameters"; String content = "Dear " + session.get("user_id").toString() + " <br> <br> here's a brief report about your scenarios data upload to the SSP database." + "Please do open and carefully check the attached log file to find out whether the import was successful.<br><br>Regards,<br>SSP database admin Summary <br><br><br>"; if (emailError != "") SendEmail.send("4igsalabs@gmail.com", session.get("user_email").toString(), subject, content + emailError); } catch (Exception e) { addActionError(e.getCause().getLocalizedMessage()); scenarioReport = service.getScenarioReport(); linkAction(scenarioReport); return INPUT; } scenarioReport = service.getScenarioReport(); linkAction(scenarioReport); return SUCCESS; }
From source file:include.excel_import.Outter.java
License:Open Source License
private boolean blankTitle() { Vector vector = getTablesName(); for (int i = 0; i < vector.size(); i++) { HSSFSheet hssfsheet = wb.getSheetAt(i); HSSFRow hssfrow = hssfsheet.getRow(0); if (hssfrow == null) { message += ",SHEET"; return true; }/*from w w w . j a v a 2s . c om*/ Iterator iterator = hssfrow.cellIterator(); int j; for (j = 0; iterator.hasNext(); j++) { HSSFCell hssfcell = (HSSFCell) iterator.next(); } for (int k = 0; k < j - 1; k++) { HSSFCell hssfcell1 = hssfrow.getCell((short) k); if (hssfcell1 == null) return true; if (hssfcell1.getCellType() != 1) { message += (String) vector.elementAt(i) + "" + (k + 1) + "?<br>"; return true; } if (hssfcell1.getCellType() == 3) { message += (String) vector.elementAt(i) + "" + (k + 1) + "<br>"; return true; } } } return false; }
From source file:include.excel_import.Outter.java
License:Open Source License
private int getColumnCount(HSSFSheet hssfsheet) { HSSFRow hssfrow = hssfsheet.getRow(0); Iterator iterator = hssfrow.cellIterator(); int i;//from w ww .jav a 2 s .c om for (i = 0; iterator.hasNext(); i++) { HSSFCell hssfcell = (HSSFCell) iterator.next(); } return i; }
From source file:include.excel_import.Outter.java
License:Open Source License
public Vector getItemsName(String s) throws Exception { Vector vector = new Vector(); int i = getTablesName().indexOf(s); if (i == -1)/* w ww . j a v a 2 s. c om*/ throw new Exception("Table not found"); HSSFSheet hssfsheet = wb.getSheetAt(i); HSSFRow hssfrow = hssfsheet.getRow(0); if (hssfrow == null) return null; Iterator iterator = hssfrow.cellIterator(); int j; for (j = 0; iterator.hasNext(); j++) { HSSFCell hssfcell = (HSSFCell) iterator.next(); } for (int k = 0; k < j; k++) { HSSFCell hssfcell1 = hssfrow.getCell((short) k); if (isBlankColumn(k, hssfsheet) && hssfcell1 != null) removeColumn(k, hssfsheet); if (hssfcell1 != null) pump(vector, hssfcell1); } return vector; }
From source file:include.excel_import.Outter.java
License:Open Source License
public Vector getRowItemsValues(String s, int i) throws Exception { Vector vector = new Vector(); int j = getTablesName().indexOf(s); if (j == -1)//w ww. j a v a 2s. co m throw new Exception("Table not found"); HSSFSheet hssfsheet = wb.getSheetAt(j); HSSFRow hssfrow = hssfsheet.getRow((short) i); Iterator iterator = hssfrow.cellIterator(); int k; for (k = 0; iterator.hasNext(); k++) { HSSFCell hssfcell = (HSSFCell) iterator.next(); } for (int l = 0; l < k; l++) { HSSFCell hssfcell1 = hssfrow.getCell((short) l); pump(vector, hssfcell1); } return vector; }
From source file:include.excel_import.Outter.java
License:Open Source License
private boolean isBlankRow(HSSFRow hssfrow) { if (hssfrow == null) return true; Iterator iterator = hssfrow.cellIterator(); int i;/*w w w. j a v a 2 s. c o m*/ for (i = 0; iterator.hasNext(); i++) { HSSFCell hssfcell = (HSSFCell) iterator.next(); } for (int j = 0; j < i; j++) { HSSFCell hssfcell1 = hssfrow.getCell((short) j); if (hssfcell1 == null) return true; if (hssfcell1.getCellType() != 3) return false; } return true; }