org.apache.poi.hssf.usermodel.HSSFSheet.getRow()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(206)

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

HSSFSheet.getRow介绍

[英]Returns the logical row (not physical) 0-based. If you ask for a row that is not defined you get a null. This is to say row 4 represents the fifth row on a sheet.
[中]返回基于0的逻辑行(非物理行)。如果您请求未定义的行,则会得到null。也就是说,第4行表示图纸上的第五行。

代码示例

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

/**
 * used internally to refresh the "last row" when the last row is removed.
 */
private int findLastRow(int lastrow) {
  if (lastrow < 1) {
    return 0;
  }
  int rownum = lastrow - 1;
  HSSFRow r = getRow(rownum);
  while (r == null && rownum > 0) {
    r = getRow(--rownum);
  }
  if (r == null) {
    return 0;
  }
  return rownum;
}

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

/**
 * Returns the HSSFRow this cell belongs to
 *
 * @return the HSSFRow that owns this cell
 */
public HSSFRow getRow() {
  int rowIndex = getRowIndex();
  return _sheet.getRow(rowIndex);
}

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

/**
 * used internally to refresh the "first row" when the first row is removed.
 */
private int findFirstRow(int firstrow) {
  int rownum = firstrow + 1;
  HSSFRow r = getRow(rownum);
  while (r == null && rownum <= getLastRowNum()) {
    r = getRow(++rownum);
  }
  if (rownum > getLastRowNum())
    return 0;
  return rownum;
}

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

row = sheet.getRow(i);
if(row != null) {
  tmp = sheet.getRow(i).getPhysicalNumberOfCells();
  if(tmp > cols) cols = tmp;
row = sheet.getRow(r);
if(row != null) {
  for(int c = 0; c < cols; c++) {

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

HSSFWorkbook myWorkBook = new HSSFWorkbook(new POIFSFileSystem(new FileInputStream("E:/Project/SpringHibernet/MultiplexTicketBookingNew/web/excelSheets/Country.xlsx")));
 HSSFSheet mySheet = myWorkBook.getSheetAt(0);
 Iterator rowIter = mySheet.rowIterator();
 System.out.println(mySheet.getRow(1).getCell(0));

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

private float getRowHeightInPoints(HSSFSheet sheet, int rowNum) {
  HSSFRow row = sheet.getRow(rowNum);
  if (row == null) {
    return sheet.getDefaultRowHeightInPoints();
  }
  return row.getHeightInPoints();
}

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

if (getRow(i) != null) {
  _firstrow = i;
  break;
if (getRow(i) != null) {
  _lastrow = i;
  break;

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

@Override
public EvaluationCell getCell(int rowIndex, int columnIndex) {
  HSSFRow row = _hs.getRow(rowIndex);
  if (row == null) {
    return null;
  }
  HSSFCell cell = row.getCell(columnIndex);
  if (cell == null) {
    return null;
  }
  return new HSSFEvaluationCell(cell, this);
}

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

/**
 * Remove a row by its index
 * @param sheet a Excel sheet
 * @param rowIndex a 0 based index of removing row
 */
public static void removeRow(HSSFSheet sheet, int rowIndex) {
  int lastRowNum=sheet.getLastRowNum();
  if(rowIndex>=0&&rowIndex<lastRowNum){
    sheet.shiftRows(rowIndex+1,lastRowNum, -1);
  }
  if(rowIndex==lastRowNum){
    HSSFRow removingRow=sheet.getRow(rowIndex);
    if(removingRow!=null){
      sheet.removeRow(removingRow);
    }
  }
}

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

/**
 * Also creates cells if they don't exist
 */
private CellRange<HSSFCell> getCellRange(CellRangeAddress range) {
  int firstRow = range.getFirstRow();
  int firstColumn = range.getFirstColumn();
  int lastRow = range.getLastRow();
  int lastColumn = range.getLastColumn();
  int height = lastRow - firstRow + 1;
  int width = lastColumn - firstColumn + 1;
  List<HSSFCell> temp = new ArrayList<>(height * width);
  for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) {
    for (int colIn = firstColumn; colIn <= lastColumn; colIn++) {
      HSSFRow row = getRow(rowIn);
      if (row == null) {
        row = createRow(rowIn);
      }
      HSSFCell cell = row.getCell(colIn);
      if (cell == null) {
        cell = row.createCell(colIn);
      }
      temp.add(cell);
    }
  }
  return SSCellRange.create(firstRow, firstColumn, height, width, temp, HSSFCell.class);
}

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

hrow = getRow(cval.getRow());
lastrow = hrow;
if (hrow == null) {

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

int lastRow = sheet.getLastRowNum();
for(int j=firstRow;j<=lastRow;j++) {
  HSSFRow row = sheet.getRow(j);
  if(row == null) { continue; }

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

private void validateArrayFormulas(CellRangeAddress region) {
  // FIXME: this may be faster if it looped over array formulas directly rather than looping over each cell in
  // the region and searching if that cell belongs to an array formula
  int firstRow = region.getFirstRow();
  int firstColumn = region.getFirstColumn();
  int lastRow = region.getLastRow();
  int lastColumn = region.getLastColumn();
  for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) {
    HSSFRow row = getRow(rowIn);
    if (row == null) continue;
    
    for (int colIn = firstColumn; colIn <= lastColumn; colIn++) {
      HSSFCell cell = row.getCell(colIn);
      if (cell == null) continue;
      if (cell.isPartOfArrayFormulaGroup()) {
        CellRangeAddress arrayRange = cell.getArrayFormulaRange();
        if (arrayRange.getNumberOfCells() > 1 && region.intersects(arrayRange)) {
          String msg = "The range " + region.formatAsString() + " intersects with a multi-cell array formula. " +
              "You cannot merge cells of an array.";
          throw new IllegalStateException(msg);
        }
      }
    }
  }
}

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

HSSFRow newRow = worksheet.getRow(destinationRowNum);
HSSFRow sourceRow = worksheet.getRow(sourceRowNum);

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

HSSFRow row = getRow(rowNum);
HSSFRow row2Replace = getRow(rowNum + n);
if (row2Replace == null)
  row2Replace = createRow(rowNum + n);

代码示例来源:origin: bill1012/AdminEAP

HSSFRow row = sheet.getRow(1);
  row = sheet.getRow(i);
  String value = row.getCell(colindex).getRichStringCellValue().getString();
  if (i == contentBeginIndex) {

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

@Override
public Object getValueAt(int row, int col) {
  HSSFRow r = st.getRow(row);
  HSSFCell c = null;
  if (r != null) {
   c = r.getCell(col);
  }
  return c;
 }
 @Override

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

public Object getValueAt(int row, int col) {
 HSSFRow r = st.getRow(row);
 HSSFCell c = null;
 if (r != null) {
  c = r.getCell(col);
 }
 return c;
}
public int getRowCount() {

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

public void addCoverType(HSSFWorkbook workbook, List<Book> books) {

  HSSFSheet sheet = workbook.getSheetAt(0);
  HSSFCell cell = null;

 //row 0 is the header (not automatically added by primefaces)
 //add a fifth cell to each row
  for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
    sheet.getRow(i).createCell(4);
    cell = sheet.getRow(i).getCell(4);
    cell.setCellValue(book.get(i - 1).getCoverType());
  }
  log.debug("cover type added");
}

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

private float getRowHeightInPoints(HSSFSheet sheet, int rowNum) {
  HSSFRow row = sheet.getRow(rowNum);
  if (row == null) {
    return sheet.getDefaultRowHeightInPoints();
  }
  return row.getHeightInPoints();
}

相关文章

微信公众号

最新文章

更多

HSSFSheet类方法