2023-03-31 15:27:31 +03:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
2023-04-01 15:58:42 +03:00
|
|
|
|
namespace RhSolutions.ExcelExtensions;
|
2023-03-31 15:27:31 +03:00
|
|
|
|
|
2023-04-01 15:58:42 +03:00
|
|
|
|
public class ColumnsEnumerator: IEnumerator<Column>
|
2023-03-31 15:27:31 +03:00
|
|
|
|
{
|
|
|
|
|
public Range Range { get; }
|
2023-04-01 15:58:42 +03:00
|
|
|
|
public Table ParentTable { get; }
|
2023-03-31 15:27:31 +03:00
|
|
|
|
private int position = 0;
|
|
|
|
|
object IEnumerator.Current
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Current;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 15:58:42 +03:00
|
|
|
|
public Column Current
|
2023-03-31 15:27:31 +03:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-04-01 15:58:42 +03:00
|
|
|
|
return new Column(Range.Columns[position], ParentTable);
|
2023-03-31 15:27:31 +03:00
|
|
|
|
}
|
|
|
|
|
catch (IndexOutOfRangeException)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 15:58:42 +03:00
|
|
|
|
public ColumnsEnumerator(Range range, Table table)
|
2023-03-31 15:27:31 +03:00
|
|
|
|
{
|
|
|
|
|
Range = range;
|
|
|
|
|
ParentTable = table;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool MoveNext()
|
|
|
|
|
{
|
|
|
|
|
position++;
|
|
|
|
|
return (position <= Range.Columns.Count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
position = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|