org.apache.poi.ss.usermodel.Cell.getRowIndex()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(267)

本文整理了Java中org.apache.poi.ss.usermodel.Cell.getRowIndex()方法的一些代码示例,展示了Cell.getRowIndex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getRowIndex()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Cell
类名称:Cell
方法名:getRowIndex

Cell.getRowIndex介绍

[英]Returns row index of a row in the sheet that contains this cell
[中]返回工作表中包含此单元格的行的行索引

代码示例

代码示例来源:origin: org.apache.poi/poi

/**
 * Create a new CellAddress object.
 *
 * @param cell the Cell to get the location of
 */
public CellAddress(Cell cell) {
  this(cell.getRowIndex(), cell.getColumnIndex());
}

代码示例来源:origin: org.apache.poi/poi

public CellReference(Cell cell) {
  this(cell.getRowIndex(), cell.getColumnIndex(), false, false);
}

代码示例来源:origin: pentaho/pentaho-kettle

public String getContents() {
 try {
  Object value = getValue();
  if ( value == null ) {
   return null;
  }
  return value.toString();
 } catch ( Exception e ) {
  throw new RuntimeException( "Unable to get string content of cell ("
   + cell.getColumnIndex() + ", " + cell.getRowIndex() + ")", e );
 }
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Determines if the given {@link Cell} lies within the bounds 
 * of this range.  
 * <p>NOTE: It is up to the caller to ensure the reference is 
 * for the correct sheet, since this instance doesn't have a sheet reference.
 *
 * @param cell the Cell to check
 * @return True if the cell lies within the bounds, false otherwise.
 * @see #intersects(CellRangeAddressBase) for checking if two ranges overlap
 */
public boolean isInRange(Cell cell) {
  return isInRange(cell.getRowIndex(), cell.getColumnIndex());
}

代码示例来源:origin: pentaho/pentaho-kettle

public Object getValue() {
 try {
  switch ( getType() ) {
   case BOOLEAN_FORMULA:
   case BOOLEAN:
    return Boolean.valueOf( cell.getBooleanCellValue() );
   case DATE_FORMULA:
   case DATE:
    // Timezone conversion needed since POI doesn't support this apparently
    //
    long time = cell.getDateCellValue().getTime();
    long tzOffset = TimeZone.getDefault().getOffset( time );
    return new Date( time + tzOffset );
   case NUMBER_FORMULA:
   case NUMBER:
    return Double.valueOf( cell.getNumericCellValue() );
   case STRING_FORMULA:
   case LABEL:
    return cell.getStringCellValue();
   case EMPTY:
   default:
    return null;
  }
 } catch ( Exception e ) {
  throw new RuntimeException( "Unable to get value of cell ("
   + cell.getColumnIndex() + ", " + cell.getRowIndex() + ")", e );
 }
}

代码示例来源:origin: org.apache.poi/poi

public static CellReference getRef(Cell cell) {
  return new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), false, false);
}

代码示例来源:origin: org.apache.poi/poi

/**
 * checks if the given cell is part of the table.  Includes checking that they are on the same sheet.
 * @param cell
 * @return true if the table and cell are on the same sheet and the cell is within the table range.
 * @since 3.17 beta 1
 * @see #contains(CellReference) (prefered, faster execution and handles undefined cells)
 */
default boolean contains(Cell cell) {
  if (cell == null) return false;
  return contains(new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true));
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Calls {@link #getRange(Table, CellReference)}.  Use that instead for performance.
 * @param table
 * @param cell
 * @return default is unimplemented/null
 * @see #getRange(Table, CellReference)
 */
public final CellRangeAddressBase getRange(Table table, Cell cell) {
  if (cell == null) return null;
  return getRange(table, new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true));
}

代码示例来源:origin: org.apache.poi/poi

@Override
public CellRange<HSSFCell> removeArrayFormula(Cell cell) {
  if (cell.getSheet() != this) {
    throw new IllegalArgumentException("Specified cell does not belong to this sheet.");
  }
  CellValueRecordInterface rec = ((HSSFCell) cell).getCellValueRecord();
  if (!(rec instanceof FormulaRecordAggregate)) {
    String ref = new CellReference(cell).formatAsString();
    throw new IllegalArgumentException("Cell " + ref + " is not part of an array formula.");
  }
  FormulaRecordAggregate fra = (FormulaRecordAggregate) rec;
  CellRangeAddress range = fra.removeArrayFormula(cell.getRowIndex(), cell.getColumnIndex());
  CellRange<HSSFCell> result = getCellRange(range);
  // clear all cells in the range
  for (Cell c : result) {
    c.setCellType(CellType.BLANK);
  }
  return result;
}

代码示例来源:origin: org.apache.poi/poi

/**
 * A range is returned only for the part of the table matching this enum instance and containing the given cell.
 * Null is returned for all other cases, such as:
 * <ul>
 * <li>Cell on a different sheet than the table
 * <li>Cell outside the table
 * <li>this Enum part is not included in the table (i.e. no header/totals row)
 * <li>this Enum is for a table part not yet implemented in POI, such as pivot table elements
 * </ul>
 * The returned range can be used to determine how style options may or may not apply to this cell.
 * For example, {@link #wholeTable} borders only apply to the outer boundary of a table, while the
 * rest of the styling, such as font and color, could apply to all the interior cells as well.
 * 
 * @param table table to evaluate
 * @param cell to evaluate 
 * @return range in the table representing this class of cells, if it contains the given cell, or null if not applicable.
 * Stripe style types return only the stripe range containing the given cell, or null.
 */
public CellRangeAddressBase appliesTo(Table table, Cell cell) {
  if (cell == null) return null;
  return appliesTo(table, new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true));
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * Set specified cell format
 *
 * @param excelFieldFormat the specified format
 * @param cell             the cell to set up format
 */
private void setDataFormat( String excelFieldFormat, Cell cell ) {
 if ( log.isDebug() ) {
  logDebug( BaseMessages.getString( PKG, "ExcelWriterStep.Log.SetDataFormat", excelFieldFormat, CellReference.convertNumToColString( cell.getColumnIndex() ), cell.getRowIndex() ) );
 }
 DataFormat format = data.wb.createDataFormat();
 short formatIndex = format.getFormat( excelFieldFormat );
 CellStyle style = data.wb.createCellStyle();
 style.cloneStyleFrom( cell.getCellStyle() );
 style.setDataFormat( formatIndex );
 cell.setCellStyle( style );
}

代码示例来源:origin: stackoverflow.com

private static String getCellName(Cell cell)
{
  return CellReference.convertNumToColString(cell.getColumnIndex()) + (cell.getRowIndex() + 1);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Create a new CellAddress object.
 *
 * @param cell the Cell to get the location of
 */
public CellAddress(Cell cell) {
  this(cell.getRowIndex(), cell.getColumnIndex());
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

CellRangeAddress getRangeIfMerged(Cell cell,
                 CellRangeAddress[] mergedRanges) {
  for ( int i = 0; i < mergedRanges.length; i++ ) {
    CellRangeAddress r = mergedRanges[i];
    if (r.isInRange(cell.getRowIndex(), cell.getColumnIndex())) {
      return r;
    }
  }
  return null;
}

代码示例来源:origin: pl.edu.icm.synat/synat-console-core

private Cell createCell(int cellNo, Row row, CellStyle style, ReportType reportType, ReportAggregation aggregation) {
  Cell cell = createCell(cellNo, row, style, (String) null);
  String value = getCellText(reportType, aggregation, cell.getRowIndex(), cell.getColumnIndex());
  cell.setCellValue(value);
  return cell;
}

代码示例来源:origin: asakusafw/asakusafw

private void fillRuleTotalCondition(Sheet sheet) {
  assert sheet != null;
  Cell value = getCell(sheet, RuleSheetFormat.TOTAL_CONDITION, 0, 1);
  value.setCellStyle(info.optionsStyle);
  String[] options = TotalConditionKind.getOptions();
  value.setCellValue(options[0]);
  setExplicitListConstraint(sheet, options,
      value.getRowIndex(), value.getColumnIndex(),
      value.getRowIndex(), value.getColumnIndex());
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Calls {@link #getRange(Table, CellReference)}.  Use that instead for performance.
 * @param table
 * @param cell
 * @return default is unimplemented/null
 * @see #getRange(Table, CellReference)
 */
public final CellRangeAddressBase getRange(Table table, Cell cell) {
  if (cell == null) return null;
  return getRange(table, new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * checks if the given cell is part of the table.  Includes checking that they are on the same sheet.
 * @param cell
 * @return true if the table and cell are on the same sheet and the cell is within the table range.
 * @since 3.17 beta 1
 * @see #contains(CellReference) (prefered, faster execution and handles undefined cells)
 */
default boolean contains(Cell cell) {
  if (cell == null) return false;
  return contains(new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true));
}

代码示例来源:origin: cn.afterturn/easypoi-base

private void addSumCellToList(Cell cell) {
  String cellValue = cell.getStringCellValue();
  int index = 0;
  while ((index = indexOfIgnoreCase(cellValue, SUM, index)) != -1) {
    TemplateSumEntity entity = new TemplateSumEntity();
    entity.setCellValue(cellValue);
    entity.setSumKey(getSumKey(cellValue, index++));
    entity.setCol(cell.getColumnIndex());
    entity.setRow(cell.getRowIndex());
    sumMap.put(entity.getSumKey(), entity);
  }
}

代码示例来源:origin: org.jeecg/easypoi-base

private void addSumCellToList(Cell cell) {
  String cellValue = cell.getStringCellValue();
  int index = 0;
  while ((index = indexOfIgnoreCase(cellValue, SUM, index)) != -1) {
    TemplateSumEntity entity = new TemplateSumEntity();
    entity.setCellValue(cellValue);
    entity.setSumKey(getSumKey(cellValue, index++));
    entity.setCol(cell.getColumnIndex());
    entity.setRow(cell.getRowIndex());
    sumMap.put(entity.getSumKey(), entity);
  }
}

相关文章