Java源码示例:org.apache.poi.ss.usermodel.Row.MissingCellPolicy
示例1
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;
}
示例2
/**
* 条件に一致するセルを探す
* @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;
}
示例3
/**
* Not supported
*/
@Override
public MissingCellPolicy getMissingCellPolicy() {
throw new UnsupportedOperationException();
}
示例4
/**
* Not supported
*/
@Override
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
throw new UnsupportedOperationException();
}
示例5
/**
* Not supported
*/
@Override
public MissingCellPolicy getMissingCellPolicy() {
throw new UnsupportedOperationException();
}
示例6
/**
* Not supported
*/
@Override
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
throw new UnsupportedOperationException();
}
示例7
/**
* Not supported
*/
@Override
public MissingCellPolicy getMissingCellPolicy() {
throw new UnsupportedOperationException();
}
示例8
/**
* Not supported
*/
@Override
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
throw new UnsupportedOperationException();
}
示例9
/**
* 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();
示例10
/**
* 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);
示例11
/**
* 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;
}
示例12
/**
* 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;
}