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