List of usage examples for org.apache.poi.hssf.usermodel HSSFSheet getRow
@Override public HSSFRow getRow(int rowIndex)
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)/*from w w w .j a v a 2 s . c o 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
public boolean hasBlank() { for (int i = 0; i < wb.getNumberOfSheets(); i++) { HSSFSheet hssfsheet = wb.getSheetAt(i); String s = wb.getSheetName(i); for (int j = 0; j < getRowCount(hssfsheet); j++) { HSSFRow hssfrow = hssfsheet.getRow(j); for (int k = 0; k < getColumnCount(hssfsheet); k++) { HSSFCell hssfcell = hssfrow.getCell((short) k); if (hssfcell == null) { message += s + "(" + (k + 1) + ":" + (j + 1) + ")(" + s + "" + getRowCount(hssfsheet) + "??)<br>"; return true; }/*from w w w. j a va2 s .c o m*/ } } } return false; }
From source file:include.excel_import.Outter.java
License:Open Source License
private boolean isBlankColumn(int i, HSSFSheet hssfsheet) { int j = getRowCount(hssfsheet); for (int k = 0; k < j; k++) { HSSFRow hssfrow = hssfsheet.getRow(k); if (hssfrow == null) return true; HSSFCell hssfcell = hssfrow.getCell((short) i); if (hssfcell == null) return true; if (hssfcell.getCellType() != 3) return false; }// ww w. j a va2 s . c o m return true; }
From source file:include.excel_import.Outter.java
License:Open Source License
private void removeColumn(int i, HSSFSheet hssfsheet) { for (int j = 0; j < getRowCount(hssfsheet); j++) { HSSFRow hssfrow = hssfsheet.getRow(j); HSSFCell hssfcell = hssfrow.getCell((short) i); if (hssfrow != null) hssfrow.removeCell(hssfcell); }/* ww w .j av a 2 s. com*/ }
From source file:include.excel_import.Outter.java
License:Open Source License
public boolean validateValue() { for (int i = 0; i < wb.getNumberOfSheets(); i++) { HSSFSheet hssfsheet = wb.getSheetAt(i); String s = wb.getSheetName(i); for (int j = 1; j < getRowCount(hssfsheet); j++) { HSSFRow hssfrow = hssfsheet.getRow(j); HSSFRow hssfrow1 = hssfsheet.getRow(0); for (int k = 0; k < getColumnCount(hssfsheet); k++) { HSSFCell hssfcell = hssfrow1.getCell((short) k); String s1 = hssfcell.getStringCellValue(); HSSFCell hssfcell1 = hssfrow.getCell((short) k); if (!validateType(hssfcell1, s1, s)) { message += "" + (k + 1) + " : " + (j + 1) + "????<br>"; return false; }/*from w w w.j av a 2 s . c o m*/ } } } return true; }
From source file:include.excel_import.XlsInfo.java
License:Open Source License
public int getRowCount(String sheetName) { if (rowCount.containsKey(sheetName)) { return ((Integer) rowCount.get(sheetName)).intValue(); }/*from w w w . j av a2s . c o m*/ HSSFSheet sheet = getSheetForSheetName(sheetName); int rowssize = sheet.getPhysicalNumberOfRows(); int size = 0; for (int i = 0; i < rowssize; i++) { HSSFRow row = sheet.getRow(i); if (row != null) size++; row = null; } Integer mysize = new Integer(size); rowCount.put(sheetName, mysize); sheet = null; mysize = null; //System.gc(); return size; }
From source file:include.excel_import.XlsInfo.java
License:Open Source License
/** * SHEET/* w w w. j av a 2s . com*/ * @param sheet HSSFSheet * @return int */ public int getColumnCount(String sheetName) { if (columnCount.containsKey(sheetName)) { return ((Integer) columnCount.get(sheetName)).intValue(); } HSSFSheet sheet = getSheetForSheetName(sheetName); HSSFRow row = sheet.getRow(0); int size = 0; int cellssize = row.getPhysicalNumberOfCells(); for (int i = 0; i < cellssize; i++) { HSSFCell cell = row.getCell((short) i); if (cell != null) { size++; cell = null; } // end of if () } Integer mysize = new Integer(size); columnCount.put(sheetName, mysize); sheet = null; row = null; mysize = null; //System.gc(); return size; }
From source file:include.excel_import.XlsInfo.java
License:Open Source License
public Vector getColumnsName(String sheetName) { if (columnsNames.containsKey(sheetName)) { return (Vector) columnsNames.get(sheetName); }// w w w.j a va 2s .com HSSFSheet sheet = getSheetForSheetName(sheetName); getColumnsName_result.clear(); HSSFRow row = sheet.getRow((short) 0); int cellssize = row.getPhysicalNumberOfCells(); for (int i = 0; i < cellssize; i++) { HSSFCell cell = row.getCell((short) i); getColumnsName_result.addElement(cell.getStringCellValue()); cell = null; } columnsNames.put(sheetName, getColumnsName_result); sheet = null; row = null; //System.gc(); return getColumnsName_result; }
From source file:include.excel_import.XlsInfo.java
License:Open Source License
public Vector getRowValues(int rowNum, Vector columnNames, String sheetName) { getRowValues_result.clear();//from ww w . j a v a2s . com HSSFSheet sheet = getSheetForSheetName(sheetName); HSSFRow row = sheet.getRow(rowNum); for (int i = 0; i < getColumnCount(sheetName); i++) { try { Vector allColumnNames = getColumnsName(sheetName); String aName = (String) allColumnNames.elementAt(i); if (columnNames.contains(aName)) { HSSFCell cell = row.getCell((short) i); String itemType = getColumnType(aName, sheetName); dump(getRowValues_result, cell, itemType); cell = null; itemType = null; } // end of if () allColumnNames = null; aName = null; } catch (Exception e) { e.printStackTrace(); } // end of catch } sheet = null; row = null; //System.gc(); return getRowValues_result; }
From source file:include.excel_import.XlsInfo.java
License:Open Source License
public Vector getRowValues(int rowNum, String sheetName) { getRowValues_result.clear();//from www . jav a 2 s. c o m HSSFSheet sheet = getSheetForSheetName(sheetName); HSSFRow row = sheet.getRow(rowNum); for (int i = 0; i < getColumnCount(sheetName); i++) { HSSFCell cell = row.getCell((short) i); String columnName = (String) getColumnsName(sheetName).elementAt(i); String itemType = getColumnType(columnName, sheetName); dump(getRowValues_result, cell, itemType); cell = null; columnName = null; itemType = null; } sheet = null; row = null; //System.gc(); return getRowValues_result; }