org.apache.poi.ss.usermodel.Row.MissingCellPolicy Java Examples

The following examples show how to use org.apache.poi.ss.usermodel.Row.MissingCellPolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Excel97FileRecordReader.java    From components with Apache License 2.0 5 votes vote down vote up
private boolean nextKeyValue4Excel97() throws IOException {
  if (!rowIterator.hasNext()) {
    return false;
  }

  currentRow++;

  Row row = rowIterator.next();
  
  if(ExcelUtils.isEmptyRow(row)) {
    //skip empty rows
    return next();
  }

  //if not fill the schema before as no header or invalid header, set it here and as no valid name as no header, so set a name like this : field1,field2,field3
  if(schema == null) {
    schema = createSchema(row, false);
  }
  value = new GenericData.Record(schema);
  
  List<Field> fields = schema.getFields();
  
  int lastColumn = Math.max(row.getLastCellNum(), fields.size());
  
  for (int i = 0; i < lastColumn; i++) {
    String content = ExcelUtils.getCellValueAsString(row.getCell(i, MissingCellPolicy.RETURN_BLANK_AS_NULL), formulaEvaluator);
    value.put(i, content);
  }

  return true;
}
 
Example #2
Source File: CellFinder.java    From xlsmapper with Apache License 2.0 5 votes vote down vote up
/**
 * 条件に一致するセルを探す
 * @return 見つからない場合は、nullを返す。
 */
private Cell findCell() {
    
    final int rowStart = startRow < 0 ? 0 : startRow;
    final int columnStart = startColumn < 0 ? 0 : startColumn;
    
    final int maxRow = POIUtils.getRows(sheet);
    for(int i=rowStart; i < maxRow; i++) {
        final Row row = sheet.getRow(i);
        if(row == null) {
            continue;
        }
        
        final int maxCol = row.getLastCellNum();;
        for(int j=columnStart; j < maxCol; j++) {
            
            if(excludeStartPoisition && includeInStartPosition(j, i)) {
                // 開始位置を除外する場合
                continue;
            }
            
            final Cell cell = row.getCell(j, MissingCellPolicy.CREATE_NULL_AS_BLANK);
            final String cellValue = POIUtils.getCellContents(cell, config.getCellFormatter());
            if(Utils.matches(cellValue, label, config)) {
                return cell;
            }
        }
    }
    
    return null;
    
}
 
Example #3
Source File: StreamingWorkbook.java    From components with Apache License 2.0 4 votes vote down vote up
/**
 * Not supported
 */
@Override
public MissingCellPolicy getMissingCellPolicy() {
    throw new UnsupportedOperationException();
}
 
Example #4
Source File: StreamingWorkbook.java    From components with Apache License 2.0 4 votes vote down vote up
/**
 * Not supported
 */
@Override
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
    throw new UnsupportedOperationException();
}
 
Example #5
Source File: StreamingWorkbook.java    From data-prep with Apache License 2.0 4 votes vote down vote up
/**
 * Not supported
 */
@Override
public MissingCellPolicy getMissingCellPolicy() {
    throw new UnsupportedOperationException();
}
 
Example #6
Source File: StreamingWorkbook.java    From data-prep with Apache License 2.0 4 votes vote down vote up
/**
 * Not supported
 */
@Override
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
    throw new UnsupportedOperationException();
}
 
Example #7
Source File: StreamingWorkbook.java    From excel-streaming-reader with Apache License 2.0 4 votes vote down vote up
/**
 * Not supported
 */
@Override
public MissingCellPolicy getMissingCellPolicy() {
  throw new UnsupportedOperationException();
}
 
Example #8
Source File: StreamingWorkbook.java    From excel-streaming-reader with Apache License 2.0 4 votes vote down vote up
/**
 * Not supported
 */
@Override
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
  throw new UnsupportedOperationException();
}
 
Example #9
Source File: Workbook.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Retrieves the current policy on what to do when
 *  getting missing or blank cells from a row.
    * <p>
 * The default is to return blank and null cells.
 *  {@link MissingCellPolicy}
    * </p>
 */
MissingCellPolicy getMissingCellPolicy();
 
Example #10
Source File: Workbook.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the policy on what to do when
 *  getting missing or blank cells from a row.
    *
 * This will then apply to all calls to
 *  {@link Row#getCell(int)} }. See
 *  {@link MissingCellPolicy}
 */
void setMissingCellPolicy(MissingCellPolicy missingCellPolicy);
 
Example #11
Source File: HSSFWorkbook.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Retrieves the current policy on what to do when
 *  getting missing or blank cells from a row.
 * The default is to return blank and null cells.
 *  {@link MissingCellPolicy}
 */
@Override
public MissingCellPolicy getMissingCellPolicy() {
    return missingCellPolicy;
}
 
Example #12
Source File: HSSFWorkbook.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the policy on what to do when
 *  getting missing or blank cells from a row.
 * This will then apply to all calls to
 *  {@link HSSFRow#getCell(int)}}. See
 *  {@link MissingCellPolicy}.
 * Note that this has no effect on any
 *  iterators, only on when fetching Cells
 *  by their column index.
 */
@Override
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
    this.missingCellPolicy = missingCellPolicy;
}