public KCell[] getRow( int rownr ) { Cell[] cells = sheet.getRow( rownr ); XLSCell[] xlsCells = new XLSCell[cells.length]; for ( int i = 0; i < cells.length; i++ ) { if ( cells[i] != null ) { xlsCells[i] = new XLSCell( cells[i] ); } } return xlsCells; }
public static RowData createRowData(Sheet sheet, int rowNum, JexcelTransformer transformer){ return createRowData(sheet.getName(), sheet.getRow(rowNum), sheet.getRowView(rowNum), transformer); }
public int getCellCount() { Cell[] row = theSheet.getRow(rowPos); return row == null ? 0 : row.length; }
/** * {@inheritDoc} */ @Override public String[] getRow(final int rowNumber) { if (rowNumber < getNumberOfRows()) { final Cell[] row = this.delegate.getRow(rowNumber); return JxlUtils.extractContents(row); } else { return null; } }
/** * Finds a cell within a given range of cells * * @param contents the string to match * @return the Cell whose contents match the parameter, null if not found */ public Cell findCell(String contents) { Cell cell = null; boolean found = false; for (int i = 0 ; i < sheet.getRows() && found == false; i++) { Cell[] row = sheet.getRow(i); for (int j = 0 ; j < row.length && found == false; j++) { if (row[j].getContents().equals(contents)) { cell = row[j]; found = true; } } } return cell; }
/** * Get a specific row from the Excel Worksheet * You can optionally skip the first column of the row to ensure row titles are not pulled into the data set * (The first row is row 1) * * @param rowNumber * @param skipFirstColumn * @return * @throws Exception */ public HashMap<Integer, Cell> getRow(int rowNumber, boolean skipFirstColumn) throws Exception { if (this.selectedSheet.equals(null)) { throw new Exception("No sheet selected. You must select a sheet before trying to get data!"); } else if (rowNumber > this.selectedSheet.getRows()) { throw new Exception("There are only " + this.selectedSheet.getRows() + " rows in this sheet. Unable to select row " + rowNumber + "!"); } HashMap<Integer, Cell> selectedRow = new HashMap<Integer, Cell>(); for (Cell currentCell : this.selectedSheet.getRow(rowNumber - 1)) { selectedRow.put(selectedRow.size() + 1, currentCell); } if (skipFirstColumn) { selectedRow.remove(1); } return selectedRow; }
/** * Finds a cell within a given range of cells * * @param contents the string to match * @return the Cell whose contents match the parameter, null if not found */ public Cell findCell(String contents) { Cell cell = null; boolean found = false; for (int i = 0 ; i < sheet.getRows() && found == false; i++) { Cell[] row = sheet.getRow(i); for (int j = 0 ; j < row.length && found == false; j++) { if (row[j].getContents().equals(contents)) { cell = row[j]; found = true; } } } return cell; }
throw new Exception("There are only " + this.selectedSheet.getRows() + " rows in this sheet. Unable to select rows " + keyRow + " and " + valueRow + "!"); Cell[] hashMapKey = this.selectedSheet.getRow(keyRow - 1); Cell[] hashMapValue = this.selectedSheet.getRow(valueRow - 1); if (hashMapKey.length != hashMapValue.length) { throw new Exception("The rows supplied are different lengths, unable to map them!");
@Override protected List<T> prefetch() throws Exception { if(currentRow >= sheet.getRows()) { return finish(); } Cell[] tmp = sheet.getRow(currentRow++); List<T> result = new ArrayList<T>(); for(int i = 0; i < tmp.length; ++i) { Cell cell = tmp[i]; T value = this.cellTransformer != null ? this.cellTransformer.transform(cell) : (T)cell; result.add(value); } //List<Cell> result = Arrays.asList(tmp); return result; }
public static <M> List<M> parseExcel(InputStream excelInputStream, Class<M> objectClass) throws Exception { Workbook workbook = Workbook.getWorkbook(excelInputStream); Sheet sheet = workbook.getSheet(0); Cell[] header = sheet.getRow(0); List<M> modelList = new ArrayList<M>(); Map<String, ExcelModel> modelMap = getExcelModel(objectClass); for (int i = 1; i < sheet.getRows(); i++) // 表内容 { M model = objectClass.newInstance(); Cell[] columns = sheet.getRow(i); for (int j = 0; j < columns.length; j++) { Object key = excelUtil._getValue(header[j]); ExcelModel excelModel = modelMap.get(key); setModel(columns[j], excelModel, model); } modelList.add(model); } return modelList; }
Cell[] row = sheet.getRow(i); for (int j = 0; j < row.length && !found; j++)
Cell[] row = sheet.getRow(i); for (int j = 0; j < row.length && !found; j++)
row = s.getRow(i);
row = s.getRow(i);
row = s.getRow(i);
row = s.getRow(i);
row = s.getRow(i);