aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.ExcelExtensions/RowEnumerator.cs
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-04-01 15:58:42 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-04-01 15:58:42 +0300
commit448af8ecd7bf9db070e090c4b434da693ba0ae89 (patch)
treead9a06664be368ebead54b82a965aa86f0a23cca /RhSolutions.ExcelExtensions/RowEnumerator.cs
parentda29243d1d661a6e304018e3317c2ca4ea495db8 (diff)
Move Excel extensions to own project
Diffstat (limited to 'RhSolutions.ExcelExtensions/RowEnumerator.cs')
-rw-r--r--RhSolutions.ExcelExtensions/RowEnumerator.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/RhSolutions.ExcelExtensions/RowEnumerator.cs b/RhSolutions.ExcelExtensions/RowEnumerator.cs
new file mode 100644
index 0000000..fd56dcd
--- /dev/null
+++ b/RhSolutions.ExcelExtensions/RowEnumerator.cs
@@ -0,0 +1,54 @@
+using System.Collections;
+
+namespace RhSolutions.ExcelExtensions;
+
+public class RowEnumerator : IEnumerator<TableCell>
+{
+ public Range Range { get; }
+ public Table ParentTable { get; }
+ private int position = 0;
+ object IEnumerator.Current
+ {
+ get
+ {
+ return Current;
+ }
+ }
+
+ public TableCell Current
+ {
+ get
+ {
+ try
+ {
+ return new TableCell(Range.Cells[1, position], ParentTable);
+ }
+ catch (IndexOutOfRangeException)
+ {
+ throw new InvalidOperationException();
+ }
+ }
+ }
+
+ public RowEnumerator(Range range, Table parentTable)
+ {
+ Range = range;
+ ParentTable = parentTable;
+ }
+
+ public bool MoveNext()
+ {
+ position++;
+ return (position <= Range.Columns.Count);
+ }
+
+ public void Reset()
+ {
+ position = 0;
+ }
+
+ public void Dispose()
+ {
+
+ }
+} \ No newline at end of file