RhSolutions-AddIn/RhSolutions.AddIn/ExcelTable/ExcelRows.cs
2023-03-31 15:27:31 +03:00

40 lines
866 B
C#

using System.Collections;
namespace RhSolutions.ExcelTable;
public class ExcelRows : IEnumerable<ExcelRow>
{
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<ExcelRow> GetEnumerator()
{
return new ExcelRowsEnumerator(Range, ParentTable);
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}