Class RangeRow
A class that represents a single row of cells.
Inherited Members
Namespace: IronXL
Assembly: IronXL.dll
Syntax
public class RangeRow : Range, IEnumerable<Cell>, IEnumerable
Properties
Height
Gets or sets the height of the row.
Declaration
public int Height { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Hidden
Gets or sets a value indicating whether this row is hidden.
Declaration
public bool Hidden { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
RowNumber
0-based index of the row.
Declaration
public int RowNumber { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
AutoSizeRow()
Changes height of the row to fit the content based on font measurements.
This method measures the text in the cell based on the font that is used for the cell.
If the exact font is not found on the machine, it will try to measure with a default font (Arial).
------------------------------------------------
Usage:
// Auto-size row 5 to fit its content
var workbook = WorkBook.Load("example.xlsx");
var sheet = workbook.DefaultWorkSheet;
var row = sheet.GetRow(5);
row.AutoSizeRow();
workbook.SaveAs("autosized.xlsx");
------------------------------------------------
Declaration
public void AutoSizeRow()
Remarks
Important Considerations:
⚠️ Font Availability: The exact font must be installed on the system for accurate measurements.
📝 Note: This overload does not consider merged cells. Use AutoSizeRow(true) to include merged cells.
Related Documentation:📖 How-To Guide:AutoSize Rows and Columns Guide
📚 API Reference:RangeRow API Documentation
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the row cannot be auto-sized. |
SixLabors.Fonts.FontException | Thrown when no fonts are found installed on the machine. |
AutoSizeRow(Boolean)
Changes height of the row to fit the content based on font measurements.
This method measures the text in the cell based on the font that is used for the cell.
If the exact font is not found on the machine, it will try to measure with a default font (Arial).
------------------------------------------------
Usage:
// Auto-size row 5 including merged cells
var workbook = WorkBook.Load("example.xlsx");
var sheet = workbook.DefaultWorkSheet;
var row = sheet.GetRow(5);
row.AutoSizeRow(true); // Include merged cells
workbook.SaveAs("autosized.xlsx");
------------------------------------------------
Declaration
public void AutoSizeRow(bool useMergedCells)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | useMergedCells | If true, the height of merged cells will be considered. |
Remarks
Important Considerations:
⚠️ Font Availability: The exact font must be installed on the system for accurate measurements.
📝 Merged Cells: When useMergedCells is true, the height calculation considers cells that span multiple rows.
🎯 Wrap Text: If cells have wrap text enabled, the height will be adjusted to show all wrapped content.
Related Documentation:📖 How-To Guide:AutoSize Rows and Columns Guide
📚 API Reference:RangeRow API Documentation
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the row cannot be auto-sized. |
SixLabors.Fonts.FontException | Thrown when no fonts are found installed on the machine. |
RemoveRow()
Removes the row from the worksheet.
Declaration
public void RemoveRow()