Row.MissingCellPolicy
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 |
---|---|
java.util.Iterator<Cell> |
cellIterator()
Cell iterator over the physically defined cells:
|
int |
compareTo(XSSFRow other)
Compares two
XSSFRow objects. |
void |
copyRowFrom(Row srcRow,
CellCopyPolicy policy)
Copy the cells from srcRow to this row
If this row is not a blank row, this will merge the two rows, overwriting
the cells in this row with the cells in srcRow
If srcRow is null, overwrite cells in destination row with blank values, styles, etc per cell copy policy
srcRow may be from a different sheet in the same workbook
|
XSSFCell |
createCell(int columnIndex)
Use this to create new cells within the row and return it.
|
XSSFCell |
createCell(int columnIndex,
CellType type)
Use this to create new cells within the row and return it.
|
boolean |
equals(java.lang.Object obj) |
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 0-based 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 |
getOutlineLevel()
Returns the rows outline level.
|
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
|
int |
hashCode() |
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
|
void |
shiftCellsLeft(int firstShiftColumnIndex,
int lastShiftColumnIndex,
int step)
Shifts column range [firstShiftColumnIndex-lastShiftColumnIndex] step places to the left.
|
void |
shiftCellsRight(int firstShiftColumnIndex,
int lastShiftColumnIndex,
int step)
Shifts column range [firstShiftColumnIndex-lastShiftColumnIndex] step places to the right.
|
java.lang.String |
toString() |
protected 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 java.util.Iterator<Cell> cellIterator()
for (Iteratorit = row.cellIterator(); it.hasNext(); ) { Cell cell = it.next(); ... } |
cellIterator
in interface Row
public java.util.Iterator<Cell> iterator()
cellIterator()
to allow foreach loops:
for(Cell cell : row){ ... }
iterator
in interface java.lang.Iterable<Cell>
public int compareTo(XSSFRow other)
XSSFRow
objects. Two rows are equal if they belong to the same worksheet and
their row indexes are equal.compareTo
in interface java.lang.Comparable<XSSFRow>
other
- the XSSFRow
to be compared.0
if the row number of this XSSFRow
is
equal to the row number of the argument XSSFRow
0
if the row number of this this XSSFRow
is
numerically less than the row number of the argument XSSFRow
0
if the row number of this this XSSFRow
is
numerically greater than the row number of the argument XSSFRow
java.lang.IllegalArgumentException
- if the argument row belongs to a different worksheetpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public XSSFCell createCell(int columnIndex)
The cell that is returned is a CellType.BLANK
. The type can be changed
either through calling setCellValue
or setCellType
.
createCell
in interface Row
columnIndex
- - the column number this cell representsjava.lang.IllegalArgumentException
- if columnIndex < 0 or greater than 16384,
the maximum number of columns supported by the SpreadsheetML format (.xlsx)public XSSFCell createCell(int columnIndex, CellType type)
createCell
in interface Row
columnIndex
- - the column number this cell representstype
- - the cell's data typejava.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)public XSSFCell getCell(int cellnum)
Row.MissingCellPolicy
from the parent Workbook.getCell
in interface Row
cellnum
- 0 based column numberRow.getCell(int, org.apache.poi.ss.usermodel.Row.MissingCellPolicy)
public XSSFCell getCell(int cellnum, Row.MissingCellPolicy policy)
Row.MissingCellPolicy
public short getFirstCellNum()
getFirstCellNum
in interface Row
public 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 Row
public short getHeight()
XSSFSheet.getDefaultRowHeightInPoints()
public float getHeightInPoints()
XSSFSheet.getDefaultRowHeightInPoints()
getHeightInPoints
in interface Row
XSSFSheet.getDefaultRowHeightInPoints()
public void setHeight(short height)
public void setHeightInPoints(float height)
setHeightInPoints
in interface Row
height
- the height in points. -1
resets to the default heightpublic int getPhysicalNumberOfCells()
getPhysicalNumberOfCells
in interface Row
public int getRowNum()
public void setRowNum(int rowIndex)
public boolean getZeroHeight()
getZeroHeight
in interface Row
public void setZeroHeight(boolean height)
setZeroHeight
in interface Row
height
- height is zero or not.public boolean isFormatted()
getRowStyle()
isFormatted
in interface Row
public XSSFCellStyle getRowStyle()
isFormatted()
to check first.getRowStyle
in interface Row
public void setRowStyle(CellStyle style)
setRowStyle
in interface Row
public void removeCell(Cell cell)
removeCell
in interface Row
cell
- the cell to remove@Internal public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow getCTRow()
protected void onDocumentWrite()
()
public java.lang.String toString()
toString
in class java.lang.Object
protected void shift(int n)
n
- the number of rows to move@Beta public void copyRowFrom(Row srcRow, CellCopyPolicy policy)
srcRow
- the rows to copy frompolicy
- the policy to determine what gets copiedpublic int getOutlineLevel()
Row
getOutlineLevel
in interface Row
public void shiftCellsRight(int firstShiftColumnIndex, int lastShiftColumnIndex, int step)
shiftCellsRight
in interface Row
firstShiftColumnIndex
- the column to start shiftinglastShiftColumnIndex
- the column to end shiftingstep
- length of the shifting steppublic void shiftCellsLeft(int firstShiftColumnIndex, int lastShiftColumnIndex, int step)
shiftCellsLeft
in interface Row
firstShiftColumnIndex
- the column to start shiftinglastShiftColumnIndex
- the column to end shiftingstep
- length of the shifting stepCopyright 2021 The Apache Software Foundation or its licensors, as applicable.