# Class ExcelRow

- java.lang.Object
- com.gembox.spreadsheet.ExcelColumnRowBase
- com.gembox.spreadsheet.ExcelRow

```
public final class ExcelRow
extends ExcelColumnRowBase
```

Excel row contains row options and cell range with row cells.

## Method Summary

Modifer 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. This method has the same effect as using |

`ExcelCell` | `getCell(String contextName)` Gets excel cell with the specified partial name from this row. This method has the same effect as using |

`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. |

## Method Detail

### getAllocatedCells

`public ExcelCellCollection getAllocatedCells()`

Gets only currently allocated cells for this row.

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();
}
}
```

### getCell

`public final ExcelCell getCell(int contextIndex)`

Gets excel cell at the specified index from this row. This method has the same effect as using `row.getCells().get(contextIndex)`

- Parameters:
- contextIndex -
The zero-based context index of the cell.

### getCell

`public final ExcelCell getCell(String contextName)`

Gets excel cell with the specified partial name from this row. This method has the same effect as using `row.getCells().get(contextName)`

RangeIndexingMode.Horizontal column name must be used (for example; "A", "D", etc.).

- Parameters:
- contextName -
Partial name of the cell.

### getHeight

`public int getHeight()`

Gets row height.

Unit is twip (1/20th of a point).

### getHeight

`public double getHeight(LengthUnit lengthUnit)`

Gets the height of row in arbitrary length unit.

- Parameters:
- lengthUnit -
The length unit in which to return row height.

- Returns:
The height of row in arbitrary length unit.

### setHeight

`public void setHeight(double value, LengthUnit lengthUnit)`

Sets the height of row in arbitrary length unit.

- Parameters:
- value -
Row height value.

- lengthUnit -
The length unit in which

`value`

is specified.

### setHeight

`public void setHeight(int height)`

Sets row height.

Unit is twip (1/20th of a point).

- Parameters:
- height -
Sets row height.