Class RowCollection
Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)
Collects the Aspose.Cells.Row objects that represent the individual rows in a worksheet.
public class RowCollection : IEnumerable
Inheritance
Implements
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
csharp
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
//Get first row
Row row = worksheet.Cells.Rows[0];
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Obtaining the reference of the first worksheet
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Get first row
Dim row as Row = worksheet.Cells.Rows(0)
Properties
Count
Gets the number of rows in this collection.
public int Count { get; }
Property Value
this[int]
Gets a Aspose.Cells.Row object by given row index. The Row object of given row index will be instantiated if it does not exist before.
public Row this[int rowIndex] { get; }
Property Value
Methods
Clear()
Clear all rows and cells.
public void Clear()
GetEnumerator()
Gets an enumerator that iterates rows through this collection
public IEnumerator GetEnumerator()
Returns
enumerator
Examples
csharp
[C#]
Workbook workbook = new Workbook("template.xlsx");
Cells cells = workbook.Worksheets[0].Cells;
IEnumerator en = cells.Rows.GetEnumerator();
while (en.MoveNext())
{
Row row = (Row)en.Current;
Console.WriteLine(row.Index + ": " + row.Height);
}
GetEnumerator(bool, bool)
Gets an enumerator that iterates rows through this collection
public IEnumerator GetEnumerator(bool reversed, bool sync)
Parameters
reversed
bool
whether enumerate rows in reversed order
sync
bool
whether the returned enumerator should check the modification of row collection and keep synchronized with it.
Returns
The row enumerator
Remarks
If the row collection will be modified(by operations that may cause new Row be instantiated or existing Row be removed) during the traversal with the enumerator, synchronized enumerator should be used instead of normal enumerator so that the traversal can continue from the position just after the one has been traversed by the last MoveNext(). However, together with the advantage that no element be skipped or traversed repeatedly, the disadvantage for synchronized enumerator is that the performance will be degraded a bit when comparing with normal enumerator.
GetRowByIndex(int)
Gets the row object by the position in the list.
public Row GetRowByIndex(int index)
Parameters
index
int
The position.
Returns
The Row object at given position.
RemoveAt(int)
Remove the row item at the specified index(position) in this collection.
public void RemoveAt(int index)
Parameters
index
int
zero-based index(position, not Aspose.Cells.Row.Index) of the existing row item in this collection.