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 RowsEnumerator : IEnumerator<Row>
|
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 Row Current
|
2023-03-31 15:27:31 +03:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-04-01 15:58:42 +03:00
|
|
|
|
return new Row(Range.Rows[position], ParentTable);
|
2023-03-31 15:27:31 +03:00
|
|
|
|
}
|
|
|
|
|
catch (IndexOutOfRangeException)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 15:58:42 +03:00
|
|
|
|
public RowsEnumerator(Range range, Table table)
|
2023-03-31 15:27:31 +03:00
|
|
|
|
{
|
|
|
|
|
Range = range;
|
|
|
|
|
ParentTable = table;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool MoveNext()
|
|
|
|
|
{
|
|
|
|
|
position++;
|
|
|
|
|
return (position <= Range.Rows.Count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
position = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|