54 lines
973 B
C#
54 lines
973 B
C#
using System.Collections;
|
|
|
|
namespace RhSolutions.ExcelExtensions;
|
|
|
|
public class ColumnsEnumerator: IEnumerator<Column>
|
|
{
|
|
public Range Range { get; }
|
|
public Table ParentTable { get; }
|
|
private int position = 0;
|
|
object IEnumerator.Current
|
|
{
|
|
get
|
|
{
|
|
return Current;
|
|
}
|
|
}
|
|
|
|
public Column Current
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
return new Column(Range.Columns[position], ParentTable);
|
|
}
|
|
catch (IndexOutOfRangeException)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
}
|
|
}
|
|
|
|
public ColumnsEnumerator(Range range, Table table)
|
|
{
|
|
Range = range;
|
|
ParentTable = table;
|
|
}
|
|
|
|
public bool MoveNext()
|
|
{
|
|
position++;
|
|
return (position <= Range.Columns.Count);
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
position = 0;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
} |