aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.ExcelExtensions/Columns.cs
diff options
context:
space:
mode:
Diffstat (limited to 'RhSolutions.ExcelExtensions/Columns.cs')
-rw-r--r--RhSolutions.ExcelExtensions/Columns.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/RhSolutions.ExcelExtensions/Columns.cs b/RhSolutions.ExcelExtensions/Columns.cs
new file mode 100644
index 0000000..1fbc0ef
--- /dev/null
+++ b/RhSolutions.ExcelExtensions/Columns.cs
@@ -0,0 +1,39 @@
+using System.Collections;
+
+namespace RhSolutions.ExcelExtensions;
+
+public class Columns : IEnumerable<Column>
+{
+ public Range Range { get; }
+ public Table ParentTable { get; }
+ public int Length
+ {
+ get => Range.Columns.Count;
+ }
+
+ public Columns(Range range, Table parentTable)
+ {
+ Range = range;
+ ParentTable = parentTable;
+ }
+
+ public Column this[int index]
+ {
+ get
+ {
+ if (index < 0 || index + 1 > Range.Columns.Count)
+ {
+ throw new IndexOutOfRangeException();
+ }
+
+ return new Column(Range.Columns[index + 1], ParentTable);
+ }
+ }
+
+ public IEnumerator<Column> GetEnumerator()
+ {
+ return new ColumnsEnumerator(Range, ParentTable);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+} \ No newline at end of file