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