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

55 lines
980 B
C#

using System.Collections;
namespace RhSolutions.ExcelExtensions;
public class ColumnEnumerator : IEnumerator<TableCell>
{
public Range Range { get; }
public Table ParentTable { get; }
private int position = 0;
object IEnumerator.Current
{
get
{
return Current;
}
}
public TableCell Current
{
get
{
try
{
return new TableCell(Range.Cells[position, 1], ParentTable);
}
catch (IndexOutOfRangeException)
{
throw new InvalidOperationException();
}
}
}
public ColumnEnumerator(Range range, Table table)
{
Range = range;
ParentTable = table;
}
public bool MoveNext()
{
position++;
return (position <= Range.Rows.Count);
}
public void Reset()
{
position = 0;
}
public void Dispose()
{
}
}