Modifier and Type | Interface and Description |
---|---|
static class |
Row.MissingCellPolicy
Used to specify the different possible policies
if for the case of null and blank cells
|
Modifier and Type | Method and Description |
---|---|
java.util.Iterator<Cell> |
cellIterator() |
Cell |
createCell(int column)
Use this to create new cells within the row and return it.
|
Cell |
createCell(int column,
CellType type)
Use this to create new cells within the row and return it.
|
Cell |
getCell(int cellnum)
Get the cell representing a given column (logical cell) 0-based.
|
Cell |
getCell(int cellnum,
Row.MissingCellPolicy policy)
Returns the cell at the given (0 based) index, with the specified
Row.MissingCellPolicy |
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 |
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
|
CellStyle |
getRowStyle()
Returns the whole-row cell styles.
|
Sheet |
getSheet()
Returns the Sheet 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.
|
default java.util.Iterator<Cell> |
iterator()
Alias for
cellIterator() to allow foreach loops:
|
void |
removeCell(Cell cell)
Remove the Cell from this row.
|
void |
setHeight(short height)
Set the row's height or set to ff (-1) for undefined/default-height.
|
void |
setHeightInPoints(float height)
Set the row's height in points.
|
void |
setRowNum(int rowNum)
Set the row number of this row.
|
void |
setRowStyle(CellStyle style)
Applies a whole-row cell styling to the row.
|
void |
setZeroHeight(boolean zHeight)
Set whether or not to display this row with 0 height
|
void |
shiftCellsLeft(int firstShiftColumnIndex,
int lastShiftColumnIndex,
int step) |
void |
shiftCellsRight(int firstShiftColumnIndex,
int lastShiftColumnIndex,
int step) |
default java.util.Spliterator<Cell> |
spliterator() |
Cell createCell(int column)
The cell that is returned is a CellType.BLANK
. The type can be changed
either through calling setCellValue
or setCellType
.
column
- - the column number this cell representsjava.lang.IllegalArgumentException
- if columnIndex < 0 or greater than the maximum number of supported columns
(255 for *.xls, 1048576 for *.xlsx)Cell createCell(int column, CellType type)
The cell that is returned will be of the requested type. The type can be changed either through calling setCellValue or setCellType, but there is a small overhead to doing this, so it is best to create of the required type up front.
column
- - the column number this cell representstype
- - the cell's data typejava.lang.IllegalArgumentException
- if columnIndex < 0 or greater than a maximum number of supported columns
(255 for *.xls, 1048576 for *.xlsx)void removeCell(Cell cell)
cell
- the cell to removevoid setRowNum(int rowNum)
rowNum
- the row number (0-based)java.lang.IllegalArgumentException
- if rowNum < 0int getRowNum()
Cell getCell(int cellnum)
cellnum
- 0 based column numbergetCell(int, org.apache.poi.ss.usermodel.Row.MissingCellPolicy)
Cell getCell(int cellnum, Row.MissingCellPolicy policy)
Row.MissingCellPolicy
java.lang.IllegalArgumentException
- if cellnum < 0 or the specified MissingCellPolicy is invalidshort getFirstCellNum()
short getLastCellNum()
short minColIx = row.getFirstCellNum(); short maxColIx = row.getLastCellNum(); for(short colIx=minColIx; colIx<maxColIx; colIx++) { Cell cell = row.getCell(colIx); if(cell == null) { continue; } //... do something with cell }Note: cells which had content before and were set to empty later might still be counted as cells by Excel and Apache POI, so the result of this method will include such rows and thus the returned value might be higher than expected!
int getPhysicalNumberOfCells()
void setHeight(short height)
height
- rowheight or 0xff for undefined (use sheet default)void setZeroHeight(boolean zHeight)
zHeight
- height is zero or not.boolean getZeroHeight()
void setHeightInPoints(float height)
height
- the height in points. -1
resets to the default heightshort getHeight()
Sheet.getDefaultRowHeightInPoints()
float getHeightInPoints()
Sheet.getDefaultRowHeightInPoints()
Sheet.getDefaultRowHeightInPoints()
boolean isFormatted()
getRowStyle()
CellStyle getRowStyle()
isFormatted()
to check first.void setRowStyle(CellStyle style)
java.util.Iterator<Cell> cellIterator()
default java.util.Iterator<Cell> iterator()
cellIterator()
to allow foreach loops:
for(Cell cell : row){ ... }
iterator
in interface java.lang.Iterable<Cell>
default java.util.Spliterator<Cell> spliterator()
spliterator
in interface java.lang.Iterable<Cell>
Sheet getSheet()
int getOutlineLevel()
void shiftCellsRight(int firstShiftColumnIndex, int lastShiftColumnIndex, int step)
void shiftCellsLeft(int firstShiftColumnIndex, int lastShiftColumnIndex, int step)
Copyright 2022 The Apache Software Foundation or its licensors, as applicable.