RhSolutions-AddIn/RhSolutions.ExcelExtensions/Rows.cs
2023-04-01 15:58:42 +03:00

40 lines
826 B
C#

using System.Collections;
namespace RhSolutions.ExcelExtensions;
public class Rows : IEnumerable<Row>
{
public Range Range { get; }
public Table ParentTable { get; }
public int Length
{
get => Range.Rows.Count;
}
public Rows(Range range, Table parentTable)
{
Range = range;
ParentTable = parentTable;
}
public Row this[int index]
{
get
{
if (index < 0 || index + 1 > Range.Rows.Count)
{
throw new IndexOutOfRangeException();
}
return new Row(Range.Rows[index + 1], ParentTable);
}
}
public IEnumerator<Row> GetEnumerator()
{
return new RowsEnumerator(Range, ParentTable);
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}