From 448af8ecd7bf9db070e090c4b434da693ba0ae89 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Sat, 1 Apr 2023 15:58:42 +0300 Subject: Move Excel extensions to own project --- RhSolutions.ExcelExtensions/ColumnsEnumerator.cs | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 RhSolutions.ExcelExtensions/ColumnsEnumerator.cs (limited to 'RhSolutions.ExcelExtensions/ColumnsEnumerator.cs') diff --git a/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs b/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs new file mode 100644 index 0000000..578e2b0 --- /dev/null +++ b/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs @@ -0,0 +1,54 @@ +using System.Collections; + +namespace RhSolutions.ExcelExtensions; + +public class ColumnsEnumerator: IEnumerator +{ + public Range Range { get; } + public Table ParentTable { get; } + private int position = 0; + object IEnumerator.Current + { + get + { + return Current; + } + } + + public Column Current + { + get + { + try + { + return new Column(Range.Columns[position], ParentTable); + } + catch (IndexOutOfRangeException) + { + throw new InvalidOperationException(); + } + } + } + + public ColumnsEnumerator(Range range, Table table) + { + Range = range; + ParentTable = table; + } + + public bool MoveNext() + { + position++; + return (position <= Range.Columns.Count); + } + + public void Reset() + { + position = 0; + } + + public void Dispose() + { + + } +} \ No newline at end of file -- cgit v1.2.3