## org.apache.poi.xssf.usermodel
Class XSSFRow

    java.lang.Object
      org.apache.poi.xssf.usermodel.XSSFRow

All Implemented Interfaces:
  java.lang.Comparable<XSSFRow>, java.lang.Iterable<Cell>, Row

    public class XSSFRow

extends java.lang.Object
implements Row, java.lang.Comparable<XSSFRow>

High level representation of a row of a spreadsheet.

Nested Class Summary

Nested classes/interfaces inherited from interface org.apache.poi.ss.usermodel.Row
`Row.MissingCellPolicy`

Field Summary

Fields inherited from interface org.apache.poi.ss.usermodel.Row
`CREATE_NULL_AS_BLANK, RETURN_BLANK_AS_NULL, RETURN_NULL_AND_BLANK`

Constructor Summary
`protected` `XSSFRow(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow row, XSSFSheet sheet)` Construct a XSSFRow.

Method Summary
`java.util.Iterator<Cell>` `cellIterator()` Cell iterator over the physically defined cells:
`int` `compareTo(XSSFRow row)` Compares two `XSSFRow` objects.
`XSSFCell` `createCell(int columnIndex)` Use this to create new cells within the row and return it.
`XSSFCell` `createCell(int columnIndex, int type)` Use this to create new cells within the row and return it.
`XSSFCell` `getCell(int cellnum)` Returns the cell at the given (0 based) index, with the `Row.MissingCellPolicy` from the parent Workbook.
`XSSFCell` `getCell(int cellnum, Row.MissingCellPolicy policy)` Returns the cell at the given (0 based) index, with the specified `Row.MissingCellPolicy`
`org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow` `getCTRow()` Returns the underlying CTRow xml bean containing all cell definitions in this row
`short` `getFirstCellNum()` Get the number of the first cell contained in this row.
`short` `getHeight()` Get the row's height measured in twips (1/20th of a point).
`float` `getHeightInPoints()` Returns row height measured in point size.
`short` `getLastCellNum()` Gets the index of the last cell contained in this row PLUS ONE.
`int` `getPhysicalNumberOfCells()` Gets the number of defined cells (NOT number of cells in the actual row!).
`int` `getRowNum()` Get row number this row represents
`XSSFCellStyle` `getRowStyle()` Returns the whole-row cell style.
`XSSFSheet` `getSheet()` Returns the XSSFSheet this row belongs to
`boolean` `getZeroHeight()` Get whether or not to display this row with 0 height
`boolean` `isFormatted()` Is this row formatted? Most aren't, but some rows do have whole-row styles.
`java.util.Iterator<Cell>` `iterator()` Alias for `cellIterator()` to allow foreach loops:
`protected void` `onDocumentWrite()` Fired when the document is written to an output stream.
`void` `removeCell(Cell cell)` Remove the Cell from this row.
`void` `setHeight(short height)` Set the height in "twips" or 1/20th of a point.
`void` `setHeightInPoints(float height)` Set the row's height in points.
`void` `setRowNum(int rowIndex)` Set the row number of this row.
`void` `setRowStyle(CellStyle style)` Applies a whole-row cell styling to the row.
`void` `setZeroHeight(boolean height)` Set whether or not to display this row with 0 height
`protected void` `shift(int n)` update cell references when shifting rows
`java.lang.String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### XSSFRow

    protected XSSFRow(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow row,
                      XSSFSheet sheet)

  Construct a XSSFRow.

  Parameters:
    `row` - the xml bean containing all cell definitions for this row.
    `sheet` - the parent sheet.

Method Detail

### getSheet

    public XSSFSheet getSheet()

  Returns the XSSFSheet this row belongs to

  Specified by:
    `getSheet` in interface `Row`
  Returns:
    the XSSFSheet that owns this row

### cellIterator

    public java.util.Iterator<Cell> cellIterator()

  Cell iterator over the physically defined cells:

  >      for (Iterator<Cell> it = row.cellIterator(); it.hasNext(); ) {
  >          Cell cell = it.next();
  >          ...
  >      }

  Specified by:
    `cellIterator` in interface `Row`
  Returns:
    an iterator over cells in this row.

### iterator

    public java.util.Iterator<Cell> iterator()

  Alias for `cellIterator()` to allow foreach loops:

  >      for(Cell cell : row){
  >          ...
  >      }

  Specified by:
    `iterator` in interface `java.lang.Iterable<Cell>`
  Returns:
    an iterator over cells in this row.

### compareTo

    public int compareTo(XSSFRow row)

  Compares two `XSSFRow` objects. Two rows are equal if they belong to the same worksheet and their row indexes are equal.

  Specified by:
    `compareTo` in interface `java.lang.Comparable<XSSFRow>`
  Parameters:
    `row` - the `XSSFRow` to be compared.
  Returns:
    the value `0` if the row number of this `XSSFRow` is equal to the row number of the argument `XSSFRow`; a value less than `0` if the row number of this this `XSSFRow` is numerically less than the row number of the argument `XSSFRow`; and a value greater than `0` if the row number of this this `XSSFRow` is numerically greater than the row number of the argument `XSSFRow`.
  Throws:
    `java.lang.IllegalArgumentException` - if the argument row belongs to a different worksheet

### createCell

    public XSSFCell createCell(int columnIndex)

  Use this to create new cells within the row and return it.

  The cell that is returned is a `Cell.CELL_TYPE_BLANK`. The type can be changed either through calling `setCellValue` or `setCellType`.

  Specified by:
    `createCell` in interface `Row`
  Parameters:
    `columnIndex` - - the column number this cell represents
  Returns:
    Cell a high level representation of the created cell.
  Throws:
    `java.lang.IllegalArgumentException` - if columnIndex < 0 or greater than 16384, the maximum number of columns supported by the SpreadsheetML format (.xlsx)

### createCell

    public XSSFCell createCell(int columnIndex,
                               int type)

  Use this to create new cells within the row and return it.

  Specified by:
    `createCell` in interface `Row`
  Parameters:
    `columnIndex` - - the column number this cell represents
    `type` - - the cell's data type
  Returns:
    XSSFCell a high level representation of the created cell.
  Throws:
    `java.lang.IllegalArgumentException` - if the specified cell type is invalid, columnIndex < 0 or greater than 16384, the maximum number of columns supported by the SpreadsheetML format (.xlsx)
  See Also:
    `Cell.CELL_TYPE_BLANK`, `Cell.CELL_TYPE_BOOLEAN`, `Cell.CELL_TYPE_ERROR`, `Cell.CELL_TYPE_FORMULA`, `Cell.CELL_TYPE_NUMERIC`, `Cell.CELL_TYPE_STRING`

### getCell

    public XSSFCell getCell(int cellnum)

  Returns the cell at the given (0 based) index, with the `Row.MissingCellPolicy` from the parent Workbook.

  Specified by:
    `getCell` in interface `Row`
  Parameters:
    `cellnum` - 0 based column number
  Returns:
    the cell at the given (0 based) index
  See Also:
    `Row.getCell(int, org.apache.poi.ss.usermodel.Row.MissingCellPolicy)`

### getCell

    public XSSFCell getCell(int cellnum,
                            Row.MissingCellPolicy policy)

  Returns the cell at the given (0 based) index, with the specified `Row.MissingCellPolicy`

  Specified by:
    `getCell` in interface `Row`
  Returns:
    the cell at the given (0 based) index
  Throws:
    `java.lang.IllegalArgumentException` - if cellnum < 0 or the specified MissingCellPolicy is invalid
  See Also:
    `Row.RETURN_NULL_AND_BLANK`, `Row.RETURN_BLANK_AS_NULL`, `Row.CREATE_NULL_AS_BLANK`

### getFirstCellNum

    public short getFirstCellNum()

  Get the number of the first cell contained in this row.

  Specified by:
    `getFirstCellNum` in interface `Row`
  Returns:
    short representing the first logical cell in the row, or -1 if the row does not contain any cells.

### getLastCellNum

    public short getLastCellNum()

  Gets the index of the last cell contained in this row PLUS ONE. The result also happens to be the 1-based column number of the last cell. This value can be used as a standard upper bound when iterating over cells:

       short minColIx = row.getFirstCellNum();
       short maxColIx = row.getLastCellNum();
       for(short colIx=minColIx; colIx<maxColIx; colIx++) {
         XSSFCell cell = row.getCell(colIx);
         if(cell == null) {
           continue;
         }
         //... do something with cell
       }

  Specified by:
    `getLastCellNum` in interface `Row`
  Returns:
    short representing the last logical cell in the row PLUS ONE, or -1 if the row does not contain any cells.

### getHeight

    public short getHeight()

  Get the row's height measured in twips (1/20th of a point). If the height is not set, the default worksheet value is returned, See `XSSFSheet.getDefaultRowHeightInPoints()`

  Specified by:
    `getHeight` in interface `Row`
  Returns:
    row height measured in twips (1/20th of a point)

### getHeightInPoints

    public float getHeightInPoints()

  Returns row height measured in point size. If the height is not set, the default worksheet value is returned, See `XSSFSheet.getDefaultRowHeightInPoints()`

  Specified by:
    `getHeightInPoints` in interface `Row`
  Returns:
    row height measured in point size
  See Also:
    `XSSFSheet.getDefaultRowHeightInPoints()`

### setHeight

    public void setHeight(short height)

  Set the height in "twips" or 1/20th of a point.

  Specified by:
    `setHeight` in interface `Row`
  Parameters:
    `height` - the height in "twips" or 1/20th of a point. `-1` resets to the default height

### setHeightInPoints

    public void setHeightInPoints(float height)

  Set the row's height in points.

  Specified by:
    `setHeightInPoints` in interface `Row`
  Parameters:
    `height` - the height in points. `-1` resets to the default height

### getPhysicalNumberOfCells

    public int getPhysicalNumberOfCells()

  Gets the number of defined cells (NOT number of cells in the actual row!). That is to say if only columns 0,4,5 have values then there would be 3.

  Specified by:
    `getPhysicalNumberOfCells` in interface `Row`
  Returns:
    int representing the number of defined cells in the row.

### getRowNum

    public int getRowNum()

  Get row number this row represents

  Specified by:
    `getRowNum` in interface `Row`
  Returns:
    the row number (0 based)

### setRowNum

    public void setRowNum(int rowIndex)

  Set the row number of this row.

  Specified by:
    `setRowNum` in interface `Row`
  Parameters:
    `rowIndex` - the row number (0-based)
  Throws:
    `java.lang.IllegalArgumentException` - if rowNum < 0 or greater than 1048575

### getZeroHeight

    public boolean getZeroHeight()

  Get whether or not to display this row with 0 height

  Specified by:
    `getZeroHeight` in interface `Row`
  Returns:
    - height is zero or not.

### setZeroHeight

    public void setZeroHeight(boolean height)

  Set whether or not to display this row with 0 height

  Specified by:
    `setZeroHeight` in interface `Row`
  Parameters:
    `height` - height is zero or not.

### isFormatted

    public boolean isFormatted()

  Is this row formatted? Most aren't, but some rows do have whole-row styles. For those that do, you can get the formatting from `getRowStyle()`

  Specified by:
    `isFormatted` in interface `Row`

### getRowStyle

    public XSSFCellStyle getRowStyle()

  Returns the whole-row cell style. Most rows won't have one of these, so will return null. Call `isFormatted()` to check first.

  Specified by:
    `getRowStyle` in interface `Row`

### setRowStyle

    public void setRowStyle(CellStyle style)

  Applies a whole-row cell styling to the row. If the value is null then the style information is removed, causing the cell to used the default workbook style.

  Specified by:
    `setRowStyle` in interface `Row`

### removeCell

    public void removeCell(Cell cell)

  Remove the Cell from this row.

  Specified by:
    `removeCell` in interface `Row`
  Parameters:
    `cell` - the cell to remove

### getCTRow

    @Internal
    public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow getCTRow()

  Returns the underlying CTRow xml bean containing all cell definitions in this row

  Returns:
    the underlying CTRow xml bean

### onDocumentWrite

    protected void onDocumentWrite()

  Fired when the document is written to an output stream.

  See Also:
    `()`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    formatted xml representation of this row

### shift

    protected void shift(int n)

  update cell references when shifting rows

  Parameters:
    `n` - the number of rows to move

Copyright 2012 The Apache Software Foundation or its licensors, as applicable.