public final class ExcelRow extends ExcelColumnRowBase
Modifier and Type | Method and Description |
---|---|
ExcelCellCollection |
getAllocatedCells()
Gets only currently allocated cells for this row.
|
ExcelCell |
getCell(int contextIndex)
Gets excel cell at the specified index from this row.
|
ExcelCell |
getCell(String contextName)
Gets excel cell with the specified partial name from this row.
|
int |
getHeight()
Gets row height.
|
double |
getHeight(LengthUnit lengthUnit)
Gets the height of row in arbitrary length unit.
|
void |
setHeight(double value,
LengthUnit lengthUnit)
Sets the height of row in arbitrary length unit.
|
void |
setHeight(int height)
Sets row height.
|
equals, getCells, getExtentEmuVisible, getIndex, getName, getOutlineLevel, getStyle, hashCode, isCollapsed, isHidden, setCollapsed, setHidden, setOutlineLevel, setStyle, toString
public ExcelCellCollection getAllocatedCells()
Use this collection if you are reading entire Excel file (you don't know exact position of
cells with data). If writing values, using ExcelColumnRowBase.getCells()
method is recommended.
This collection contains only allocated cells so it is faster as you avoid checking every single cell in a row. You still need to check if a specific cell contains any value (it can be empty).
Following code reads entire XLSX file and displays all cells containing any data. Data types are also displayed.
ExcelFile ef = ExcelFile.load("Book1.xlsx");
for (ExcelWorksheet sheet : ef.getWorksheets()) {
System.out.println(sheet.getName());
for (ExcelRow row : sheet.getRows()) {
for (ExcelCell cell : row.getAllocatedCells()) {
if (cell.getValue() != null)
System.out.println(cell.getValue() + "-" + cell.getValue().getClass().getName());
System.out.print("\t");
}
System.out.println();
}
}
ExcelColumnRowBase.getCells()
,
ExcelCell
public final ExcelCell getCell(int contextIndex)
row.getCells()
.get(contextIndex)
contextIndex
- The zero-based context index of the cell.CellRange.get(int)
public final ExcelCell getCell(String contextName)
row.getCells()
.get(contextName)
RangeIndexingMode.Horizontal
column name
must be used (for example; "A", "D", etc.).contextName
- Partial name of the cell.CellRange.get(String)
public int getHeight()
Unit is twip (1/20th of a point).
public double getHeight(LengthUnit lengthUnit)
lengthUnit
- The length unit in which to return row height.public void setHeight(double value, LengthUnit lengthUnit)
value
- Row height value.lengthUnit
- The length unit in which value
is specified.public void setHeight(int height)
Unit is twip (1/20th of a point).
© GemBox Ltd. — All rights reserved.