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

39 lines
855 B
C#

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