aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.ExcelExtensions/RowsEnumerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'RhSolutions.ExcelExtensions/RowsEnumerator.cs')
-rw-r--r--RhSolutions.ExcelExtensions/RowsEnumerator.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/RhSolutions.ExcelExtensions/RowsEnumerator.cs b/RhSolutions.ExcelExtensions/RowsEnumerator.cs
new file mode 100644
index 0000000..b53db98
--- /dev/null
+++ b/RhSolutions.ExcelExtensions/RowsEnumerator.cs
@@ -0,0 +1,55 @@
+using System.Collections;
+
+namespace RhSolutions.ExcelExtensions;
+
+public class RowsEnumerator : IEnumerator<Row>
+{
+ public Range Range { get; }
+ public Table ParentTable { get; }
+ private int position = 0;
+ object IEnumerator.Current
+ {
+ get
+ {
+ return Current;
+ }
+ }
+
+ public Row Current
+ {
+ get
+ {
+ try
+ {
+ return new Row(Range.Rows[position], ParentTable);
+ }
+ catch (IndexOutOfRangeException)
+ {
+ throw new InvalidOperationException();
+ }
+ }
+ }
+
+ public RowsEnumerator(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()
+ {
+
+ }
+
+} \ No newline at end of file