Row

Row class

Represents a single row in a worksheet.

public class Row : IEnumerable

Properties

Name Description
FirstCell { get; } Gets the first cell object in the row.
FirstDataCell { get; } Gets the first non-blank cell in the row.
GroupLevel { get; } Gets the group level of the row.
Height { get; set; } Gets and sets the row height in unit of Points.
Index { get; } Gets the index of this row.
IsBlank { get; } Indicates whether the row contains any data
IsCollapsed { get; set; } whether the row is collapsed
IsHeightMatched { get; set; } Indicates that row height and default font height matches.
IsHidden { get; set; } Indicates whether the row is hidden.
Item { get; } Gets the cell.
LastCell { get; } Gets the last cell object in the row.
LastDataCell { get; } Gets the last non-blank cell in the row.
Style { get; } Represents the style of this row.

Methods

Name Description
ApplyStyle(Style, StyleFlag) Applies formats for a whole row.
CopySettings(Row, bool) Copy settings of row, such as style, height, visibility, …etc.
Equals(object) Checks whether this object refers to the same row with another.
Equals(Row) Checks whether this object refers to the same row with another row object.
GetCellByIndex(int) Get the cell by specific index in the list.
GetCellOrNull(int) Gets the cell or null in the specific index.
GetEnumerator() Gets the cells enumerator

Examples


[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
Style style = workbook.CreateStyle();

//Setting the background color to Blue
style.BackgroundColor = Color.Blue;

//Setting the foreground color to Red
style.ForegroundColor= Color.Red;

//setting Background Pattern
style.Pattern = BackgroundType.DiagonalStripe;

//New Style Flag
StyleFlag styleFlag = new StyleFlag();

//Set All Styles
styleFlag.All = true;

 //Get first row
Row row = worksheet.Cells.Rows[0];
 //Apply Style to first row
row.ApplyStyle(style, styleFlag);

//Saving the Excel file
workbook.Save("book1.xls");

[VB.NET]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()

'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)

Dim style As Style = workbook.CreateStyle()

'Setting the background color to Blue
style.BackgroundColor = Color.Blue

'Setting the foreground color to Red
style.ForegroundColor = Color.Red

'setting Background Pattern
style.Pattern = BackgroundType.DiagonalStripe

'New Style Flag
Dim styleFlag As New StyleFlag()

'Set All Styles
styleFlag.All = True

 'Get first row
Dim row as Row = worksheet.Cells.Rows(0)
 'Apply Style to first row
row.ApplyStyle(style, styleFlag)

'Saving the Excel file
workbook.Save("book1.xls")

See Also