List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet rowIterator
@Override
public Iterator<Row> rowIterator()
From source file:guineu.data.parser.impl.ParserXLS.java
License:Open Source License
public int getNumberRows(int init, HSSFSheet sheet) { Iterator rowIt = sheet.rowIterator(); int num = 0;/*from ww w . j a v a 2 s . c om*/ while (rowIt.hasNext()) { HSSFRow row = (HSSFRow) rowIt.next(); HSSFCell cell; cell = row.getCell(0); if ((cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) && row.getRowNum() > init) { break; } num = row.getRowNum(); } return num - init; }
From source file:guineu.modules.configuration.parameters.ParameterDialog.java
License:Open Source License
public void readRows(HSSFSheet sheet) { try {/*from w w w .j a va2 s . co m*/ Iterator rowIt = sheet.rowIterator(); HSSFRow row = (HSSFRow) rowIt.next(); for (int i = 1; i < row.getLastCellNum(); i++) { HSSFCell cell = row.getCell(i); model.addColumn(cell.toString()); } ((ParameterDataModel) model).fireTableStructureChanged(); table.getColumnModel().getColumn(0).setMinWidth(300); int rowIndex = -1; while (rowIt.hasNext()) { row = (HSSFRow) rowIt.next(); HSSFCell cell; cell = row.getCell(0); for (int e = 0; e < model.getRowCount(); e++) { String sampleName = model.getValueAt(e, 0); if (sampleName.equals(cell.toString())) { rowIndex = e; } } for (int i = 1; i < row.getLastCellNum(); i++) { cell = row.getCell(i); model.setValueAt(cell.toString(), rowIndex, i); } } ((ParameterDataModel) model).addParameters(dataset); ((ParameterDataModel) model).fireTableDataChanged(); } catch (Exception e) { e.printStackTrace(); } }
From source file:include.excel_import.Outter.java
License:Open Source License
public Vector getItemValues(String s, String s1) throws Exception { Vector vector = new Vector(); int i = getItemsName(s1).indexOf(s); if (i == -1)/* w w w. j a v a2s . c o m*/ throw new Exception("Item not found"); HSSFSheet hssfsheet = wb.getSheetAt(getTablesName().indexOf(s1)); Iterator iterator = hssfsheet.rowIterator(); int j = 0; while (iterator.hasNext()) if (hssfsheet != null) { HSSFRow hssfrow = (HSSFRow) iterator.next(); HSSFCell hssfcell = hssfrow.getCell((short) i); if (j > 0 && hssfcell != null) pump(vector, hssfcell, getItemType(s, s1)); j++; } return vector; }
From source file:include.excel_import.Outter.java
License:Open Source License
public int getRowCount(String s) throws Exception { int i = getTablesName().indexOf(s); if (i == -1)/*from w w w . j a v a2s . c om*/ throw new Exception("Table not found"); HSSFSheet hssfsheet = wb.getSheetAt(i); Iterator iterator = hssfsheet.rowIterator(); int j = 0; while (iterator.hasNext()) { HSSFRow hssfrow = (HSSFRow) iterator.next(); if (hssfrow != null) j++; } return j; }
From source file:include.excel_import.Outter.java
License:Open Source License
private int getRowCount(HSSFSheet hssfsheet) { Iterator iterator = hssfsheet.rowIterator(); int i = 0;//from w ww. j a v a 2s . c o m while (iterator.hasNext()) { HSSFRow hssfrow = (HSSFRow) iterator.next(); if (hssfrow != null) i++; } return i; }
From source file:javaexcel.LeyendoExcel.java
private void leeFicheroExcel(String fileName) { List cellDataList = new ArrayList(); try {// w ww .j ava2 s. co m // POIFSFileSystem: ciclo de vida completo del sistema de archivos. // HSSFWorkbook: primer objeto construido. // HSSFSheet: hojas de clculo. // HSSFRow: fila de una hoja de clculo. // HSSFCell: celda en una fila de la hoja de clculo. FileInputStream fileInputStream = new FileInputStream(fileName); POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream); HSSFWorkbook libro = new HSSFWorkbook(fsFileSystem); HSSFSheet hoja = libro.getSheetAt(0); Iterator rowIterator = hoja.rowIterator(); while (rowIterator.hasNext()) { HSSFRow fila = (HSSFRow) rowIterator.next(); Iterator iterator = fila.cellIterator(); List cellTempList = new ArrayList(); while (iterator.hasNext()) { HSSFCell hssfCell = (HSSFCell) iterator.next(); cellTempList.add(hssfCell); } cellDataList.add(cellTempList); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:LogicModel.excel_Manage.java
public static List readExcel(String path) throws IOException { //String path1 = System.getProperty("user.home")+"/ejemploExcelJava.xls"; String path1 = path;//from w w w.ja v a 2 s . co m List<List> sheetData = new ArrayList(); FileInputStream FlujoDeDatos = null; try { FlujoDeDatos = new FileInputStream(path1); if (FlujoDeDatos == null) { System.out.println("No se encuentra el archivo"); // No se encuentra la plantilla - aqui puedes enviar un mensaje de log o lo que quieras return null; } // Si todo ha ido bien HSSFWorkbook workbook = new HSSFWorkbook(FlujoDeDatos); // // Get the first sheet on the workbook. // HSSFSheet sheet = workbook.getSheetAt(0); // When we have a sheet object in hand we can iterator on // each sheet's rows and on each row's cells. We store the // data read on an ArrayList so that we can printed the // content of the excel to the console. // Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { HSSFRow row = (HSSFRow) rows.next(); Iterator cells = row.cellIterator(); List data = new ArrayList(); while (cells.hasNext()) { HSSFCell cell = (HSSFCell) cells.next(); //String cel=cell.toString(); // System.out.println("Aadiendo Celda: " + cell.toString()); data.add(cell); } sheetData.add(data); } } catch (IOException e) { e.printStackTrace(); } finally { if (FlujoDeDatos != null) { FlujoDeDatos.close(); } } //showExelData(sheetData); return sheetData; }
From source file:Login.HULogin.java
private void Login() throws Exception { String fileName = "/Users/cdp/Desktop/Aksh/TestFile.xls"; System.out.println(fileName); List sheetData = new ArrayList(); try (FileInputStream fis = new FileInputStream(fileName)) { HSSFWorkbook workbook = new HSSFWorkbook(fis); HSSFSheet sheet = workbook.getSheetAt(0); Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { HSSFRow row = (HSSFRow) rows.next(); Iterator cells = row.cellIterator(); List data = new ArrayList(); while (cells.hasNext()) { HSSFCell cell = (HSSFCell) cells.next(); data.add(cell);/*from www .j a va2s .c o m*/ } sheetData.add(data); } } catch (IOException e) { } loginData(sheetData); }
From source file:Login.HULogin.java
private void Register() throws Exception { String fileName = "/Users/cdp/Desktop/Aksh/TestData/register.xls"; System.out.println(fileName); List sheetData = new ArrayList(); try (FileInputStream fis = new FileInputStream(fileName)) { HSSFWorkbook workbook = new HSSFWorkbook(fis); HSSFSheet sheet = workbook.getSheetAt(0); Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { HSSFRow row = (HSSFRow) rows.next(); Iterator cells = row.cellIterator(); List data = new ArrayList(); while (cells.hasNext()) { HSSFCell cell = (HSSFCell) cells.next(); data.add(cell);//from w w w .j a v a 2 s. c o m } sheetData.add(data); } } catch (IOException e) { } UserData(sheetData); }
From source file:Login.ventas.fpagosvarios.java
private void readExcelFile(String fileName) { /**/* w w w .j a v a2s . co m*/ * Create a new instance for cellDataList */ cellDataList = new ArrayList(); try { /** * Create a new instance for FileInputStream class */ FileInputStream fileInputStream = new FileInputStream(fileName); /** * Create a new instance for POIFSFileSystem class */ POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream); /* * Create a new instance for HSSFWorkBook Class */ HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem); HSSFSheet hssfSheet = workBook.getSheetAt(0); /** * Iterate the rows and cells of the spreadsheet * to get all the datas. */ Iterator rowIterator = hssfSheet.rowIterator(); rowIterator.next(); while (rowIterator.hasNext()) { HSSFRow hssfRow = (HSSFRow) rowIterator.next(); Iterator iterator = hssfRow.cellIterator(); List cellTempList = new ArrayList(); while (iterator.hasNext()) { HSSFCell hssfCell = (HSSFCell) iterator.next(); cellTempList.add(hssfCell); } cellDataList.add(cellTempList); } } catch (Exception ex) { System.out.println(ex); } }