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