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.
(获取表示给定列(逻辑单元格)的单元格,从 0 开始。)
|
Cell |
getCell(int cellnum, Row.MissingCellPolicy policy)
Returns the cell at the given (0 based) index, with the specified
Row.MissingCellPolicy
(返回给定(基于 0)索引处的单元格,具有指定的 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).
(获取以缇为单位的行高(1/20 点)。)
|
float |
getHeightInPoints()
Returns row height measured in point size.
(返回以磅为单位测量的行高。)
|
short |
getLastCellNum()
Gets the index of the last cell contained in this row
PLUS ONE.
(获取此行 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
(获取是否以0高度显示该行)
|
boolean |
isFormatted()
Is this row formatted? Most aren't, but some rows do have whole-row styles.
(此行是否已格式化?大多数不是,但有些行确实具有整行样式。)
|
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.
(为未定义/默认高度设置行高或设置为 ff (-1)。)
|
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
(设置是否以0高度显示该行)
|
void |
shiftCellsLeft(int firstShiftColumnIndex, int lastShiftColumnIndex, int step) |
void |
shiftCellsRight(int firstShiftColumnIndex, int lastShiftColumnIndex, int step) |
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 represents
(column - - 此单元格代表的列号)
java.lang.IllegalArgumentException
- if columnIndex < 0 or greater than the maximum number of supported columns (255 for *.xls, 1048576 for *.xlsx)
(java.lang.IllegalArgumentException - 如果 columnIndex < 0 或大于支持的最大列数(*.xls 为 255,*.xlsx 为 1048576))
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.
(使用它在行内创建新单元格并将其返回。返回的单元格将是请求的类型。可以通过调用 setCellValue 或 setCellType 来更改类型,但这样做会产生少量开销,因此最好预先创建所需类型。)column
- - the column number this cell represents
(column - - 此单元格代表的列号)
type
- - the cell's data type
(type - - 单元格的数据类型)
java.lang.IllegalArgumentException
- if columnIndex < 0 or greater than a maximum number of supported columns (255 for *.xls, 1048576 for *.xlsx)
(java.lang.IllegalArgumentException - 如果 columnIndex < 0 或大于支持的最大列数(*.xls 为 255,*.xlsx 为 1048576))
void removeCell(Cell cell)
cell
- the cell to remove
(cell - 要删除的单元格)
void setRowNum(int rowNum)
rowNum
- the row number (0-based)
(rowNum - 行号(从 0 开始))
java.lang.IllegalArgumentException
- if rowNum < 0
(java.lang.IllegalArgumentException - 如果 rowNum < 0)
int getRowNum()
Cell getCell(int cellnum)
cellnum
- 0 based column number
(cellnum - 基于 0 的列号)
getCell(int, org.apache.poi.ss.usermodel.Row.MissingCellPolicy)
Cell getCell(int cellnum, Row.MissingCellPolicy policy)
Row.MissingCellPolicy
(返回给定(基于 0)索引处的单元格,具有指定的 Row.MissingCellPolicy)
java.lang.IllegalArgumentException
- if cellnum < 0 or the specified MissingCellPolicy is invalid
(java.lang.IllegalArgumentException - 如果 cellnum < 0 或指定的 MissingCellPolicy 无效)
short 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! (获取此行 PLUS ONE 中包含的最后一个单元格的索引。结果也恰好是最后一个单元格的基于 1 的列号。迭代单元格时,此值可用作标准上限: short minColIx = row.getFirstCellNum();短 maxColIx = row.getLastCellNum();对于(短 colIx=minColIx;colIx
int getPhysicalNumberOfCells()
void setHeight(short height)
height
- rowheight or 0xff for undefined (use sheet default)
(height - 未定义的行高或 0xff(使用工作表默认值))
void setZeroHeight(boolean zHeight)
zHeight
- height is zero or not.
(zHeight - 高度是否为零。)
boolean getZeroHeight()
void setHeightInPoints(float height)
height
- the height in points.
-1
resets to the default height
(height - 以磅为单位的高度。 -1 重置为默认高度)
short getHeight()
Sheet.getDefaultRowHeightInPoints()
(获取以缇为单位的行高(1/20 点)。如果未设置高度,则返回默认工作表值,参见 Sheet.getDefaultRowHeightInPoints())
float getHeightInPoints()
Sheet.getDefaultRowHeightInPoints()
(返回以磅为单位测量的行高。如果未设置高度,则返回默认工作表值,参见 Sheet.getDefaultRowHeightInPoints())
Sheet.getDefaultRowHeightInPoints()
boolean isFormatted()
getRowStyle()
(此行是否已格式化?大多数不是,但有些行确实具有整行样式。对于那些这样做的人,您可以从 getRowStyle() 获取格式)
CellStyle getRowStyle()
isFormatted()
to check first.
(返回整行单元格样式。大多数行不会有其中之一,因此将返回 null。首先调用 isFormatted() 进行检查。)
void setRowStyle(CellStyle style)
java.util.Iterator<Cell> cellIterator()
Sheet getSheet()
int getOutlineLevel()
void shiftCellsRight(int firstShiftColumnIndex, int lastShiftColumnIndex, int step)
void shiftCellsLeft(int firstShiftColumnIndex, int lastShiftColumnIndex, int step)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.