public class XSSFRow extends Object implements Row, Comparable<XSSFRow>
Row.MissingCellPolicyCREATE_NULL_AS_BLANK, RETURN_BLANK_AS_NULL, RETURN_NULL_AND_BLANK| Modifier | Constructor and Description |
|---|---|
protected |
XSSFRow(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow row,
XSSFSheet sheet)
Construct a XSSFRow.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
TreeMap<Integer,XSSFCell> |
getCells() |
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 |
isCustomHeight() |
boolean |
isFormatted()
Is this row formatted? Most aren't, but some rows
do have whole-row styles.
|
Iterator<Cell> |
iterator()
Alias for
cellIterator() to allow foreach loops:
|
protected void |
onDocumentWrite()
Fired when the document is written to an output stream.
|
void |
removeAllCells() |
void |
removeCell(Cell cell)
Remove the Cell from this row.
|
void |
setCustomHeight(boolean custom) |
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
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected XSSFRow(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow row,
XSSFSheet sheet)
row - the xml bean containing all cell definitions for this row.sheet - the parent sheet.public XSSFSheet getSheet()
public Iterator<Cell> cellIterator()
for (Iterator| it = row.cellIterator(); it.hasNext(); ) { Cell cell = it.next(); ... } |
cellIterator in interface Rowpublic Iterator<Cell> iterator()
cellIterator() to allow foreach loops:
for(Cell cell : row){
...
}
public int compareTo(XSSFRow row)
XSSFRow objects. Two rows are equal if they belong to the same worksheet and
their row indexes are equal.compareTo in interface Comparable<XSSFRow>row - the XSSFRow to be compared.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.IllegalArgumentException - if the argument row belongs to a different worksheetpublic XSSFCell createCell(int columnIndex)
The cell that is returned is a Cell.CELL_TYPE_BLANK. The type can be changed
either through calling setCellValue or setCellType.
createCell in interface RowcolumnIndex - - the column number this cell representsIllegalArgumentException - if columnIndex < 0 or greater than 16384,
the maximum number of columns supported by the SpreadsheetML format (.xlsx)public XSSFCell createCell(int columnIndex, int type)
createCell in interface RowcolumnIndex - - the column number this cell representstype - - the cell's data typeIllegalArgumentException - if the specified cell type is invalid, columnIndex < 0
or greater than 16384, the maximum number of columns supported by the SpreadsheetML format (.xlsx)Cell.CELL_TYPE_BLANK,
Cell.CELL_TYPE_BOOLEAN,
Cell.CELL_TYPE_ERROR,
Cell.CELL_TYPE_FORMULA,
Cell.CELL_TYPE_NUMERIC,
Cell.CELL_TYPE_STRINGpublic XSSFCell getCell(int cellnum)
Row.MissingCellPolicy from the parent Workbook.getCell in interface Rowcellnum - 0 based column numberRow.getCell(int, org.zkoss.poi.ss.usermodel.Row.MissingCellPolicy)public XSSFCell getCell(int cellnum, Row.MissingCellPolicy policy)
Row.MissingCellPolicygetCell in interface RowIllegalArgumentException - if cellnum < 0 or the specified MissingCellPolicy is invalidRow.RETURN_NULL_AND_BLANK,
Row.RETURN_BLANK_AS_NULL,
Row.CREATE_NULL_AS_BLANKpublic short getFirstCellNum()
getFirstCellNum in interface Rowpublic short getLastCellNum()
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
}
getLastCellNum in interface Rowpublic short getHeight()
XSSFSheet.getDefaultRowHeightInPoints()public float getHeightInPoints()
XSSFSheet.getDefaultRowHeightInPoints()getHeightInPoints in interface RowXSSFSheet.getDefaultRowHeightInPoints()public void setHeight(short height)
public void setHeightInPoints(float height)
setHeightInPoints in interface Rowheight - the height in points. -1 resets to the default heightpublic int getPhysicalNumberOfCells()
getPhysicalNumberOfCells in interface Rowpublic int getRowNum()
public void setRowNum(int rowIndex)
setRowNum in interface RowrowIndex - the row number (0-based)IllegalArgumentException - if rowNum < 0 or greater than 1048575public boolean getZeroHeight()
getZeroHeight in interface Rowpublic void setZeroHeight(boolean height)
setZeroHeight in interface Rowheight - height is zero or not.public boolean isFormatted()
getRowStyle()isFormatted in interface Rowpublic XSSFCellStyle getRowStyle()
isFormatted() to check first.getRowStyle in interface Rowpublic void setRowStyle(CellStyle style)
setRowStyle in interface Rowpublic void removeCell(Cell cell)
removeCell in interface Rowcell - the cell to remove@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow getCTRow()
protected void onDocumentWrite()
()public String toString()
protected void shift(int n)
n - the number of rows to movepublic void removeAllCells()
public boolean isCustomHeight()
isCustomHeight in interface Rowpublic void setCustomHeight(boolean custom)
setCustomHeight in interface RowCopyright © 2020. All rights reserved.