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/Columns.cs | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 RhSolutions.ExcelExtensions/Columns.cs (limited to 'RhSolutions.ExcelExtensions/Columns.cs') 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 +{ + 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 GetEnumerator() + { + return new ColumnsEnumerator(Range, ParentTable); + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); +} \ No newline at end of file -- cgit v1.2.3