aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.ExcelExtensions
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-04-07 09:26:52 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-04-07 09:26:52 +0300
commit3f4d7f45b7f73ec0da32cc0a5d071b7a3a1e9aa1 (patch)
treeb4b4b28a4828b4c4f55901a5b81e08778ded7b20 /RhSolutions.ExcelExtensions
parent6acba1a542d98f50e9bdaa986d81024623aeeffd (diff)
Delete Excel.Extensions
Diffstat (limited to 'RhSolutions.ExcelExtensions')
-rw-r--r--RhSolutions.ExcelExtensions/Cell.cs26
-rw-r--r--RhSolutions.ExcelExtensions/Column.cs65
-rw-r--r--RhSolutions.ExcelExtensions/Columns.cs49
-rw-r--r--RhSolutions.ExcelExtensions/ColumnsEnumerator.cs52
-rw-r--r--RhSolutions.ExcelExtensions/RhSolutions.ExcelExtensions.csproj15
-rw-r--r--RhSolutions.ExcelExtensions/Row.cs54
-rw-r--r--RhSolutions.ExcelExtensions/Rows.cs44
-rw-r--r--RhSolutions.ExcelExtensions/RowsEnumerator.cs52
-rw-r--r--RhSolutions.ExcelExtensions/Table.cs64
-rw-r--r--RhSolutions.ExcelExtensions/Usings.cs3
10 files changed, 0 insertions, 424 deletions
diff --git a/RhSolutions.ExcelExtensions/Cell.cs b/RhSolutions.ExcelExtensions/Cell.cs
deleted file mode 100644
index 19a2017..0000000
--- a/RhSolutions.ExcelExtensions/Cell.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-namespace RhSolutions.ExcelExtensions;
-
-public sealed class Cell
-{
- public Table ParentTable { get; }
- public Row ParentRow
- {
- get => ParentTable.Rows[ParentTable.Range.Row - _range.Row];
- }
- public Column ParentColumn
- {
- get => ParentTable.Columns[ParentTable.Range.Column - _range.Column];
- }
- public object Value
- {
- get => _range.Cells[1, 1].Value2;
- set => _range.Cells[1, 1].Value2 = value;
- }
- private Range _range;
-
- public Cell(Range range, Table table)
- {
- _range = range;
- ParentTable = table;
- }
-}
diff --git a/RhSolutions.ExcelExtensions/Column.cs b/RhSolutions.ExcelExtensions/Column.cs
deleted file mode 100644
index 341897c..0000000
--- a/RhSolutions.ExcelExtensions/Column.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-namespace RhSolutions.ExcelExtensions;
-
-public sealed class Column
-{
- public Table ParentTable { get; }
- public string Header
- {
- get => _range.Cells[1, 1].Value2.ToString() ?? String.Empty;
- }
- public int Index
- {
- get => _range.Column - ParentTable.Range.Column;
- }
- public int Length
- {
- get => _range.Rows.Count;
- }
- private Cell[] _cells;
- private readonly Range _range;
-
- public Column(Range range, Table table)
- {
- _cells = new Cell[range.Rows.Count];
- _range = range;
- ParentTable = table ??
- throw new ArgumentNullException("table");
- }
-
- public Cell this[int index]
- {
- get
- {
- if (_cells[index] == null)
- {
- _cells[index] = new Cell(_range.Cells[index + 1, 1], ParentTable);
- return _cells[index];
- }
- else
- {
- return _cells[index];
- }
- }
- set
- {
- if (_cells[index] == null)
- {
- _cells[index] = new Cell(_range.Cells[index + 1, 1], ParentTable);
- _cells[index].Value = value;
- }
- else
- {
- _cells[index].Value = value;
- }
- }
- }
-
- public Column AddLeft()
- {
- _range.EntireColumn
- .Insert(XlInsertShiftDirection.xlShiftToRight,
- XlInsertFormatOrigin.xlFormatFromRightOrBelow);
-
- return ParentTable.Columns[this.Index - 1];
- }
-}
diff --git a/RhSolutions.ExcelExtensions/Columns.cs b/RhSolutions.ExcelExtensions/Columns.cs
deleted file mode 100644
index 014b755..0000000
--- a/RhSolutions.ExcelExtensions/Columns.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections;
-
-namespace RhSolutions.ExcelExtensions;
-
-public class Columns : IEnumerable<Column>
-{
- public Table ParentTable { get; }
- public int Length
- {
- get => _range.Columns.Count;
- }
- private Column[] _columns;
- private Range _range;
-
- public Columns(Table parentTable)
- {
- ParentTable = parentTable;
- _range = parentTable.Range;
- _columns = new Column[Length];
- }
-
- public Column this[int index]
- {
- get
- {
- if (index < 0 || index >= Length)
- {
- throw new IndexOutOfRangeException();
- }
-
- if (_columns[index] == null)
- {
- _columns[index] = new Column(_range.Columns[index + 1], ParentTable);
- return _columns[index];
- }
- else
- {
- return _columns[index];
- }
- }
- }
-
- public IEnumerator<Column> GetEnumerator()
- {
- return new ColumnsEnumerator(this);
- }
-
- IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
-} \ No newline at end of file
diff --git a/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs b/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs
deleted file mode 100644
index 40ad4d6..0000000
--- a/RhSolutions.ExcelExtensions/ColumnsEnumerator.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Collections;
-
-namespace RhSolutions.ExcelExtensions;
-
-public class ColumnsEnumerator: IEnumerator<Column>
-{
- private Columns _columns;
- private int position = -1;
- object IEnumerator.Current
- {
- get
- {
- return Current;
- }
- }
-
- public Column Current
- {
- get
- {
- try
- {
- return _columns[position];
- }
- catch (IndexOutOfRangeException)
- {
- throw new InvalidOperationException();
- }
- }
- }
-
- public ColumnsEnumerator(Columns columns)
- {
- _columns = columns;
- }
-
- public bool MoveNext()
- {
- position++;
- return (position < _columns.Length);
- }
-
- public void Reset()
- {
- position = -1;
- }
-
- public void Dispose()
- {
-
- }
-} \ No newline at end of file
diff --git a/RhSolutions.ExcelExtensions/RhSolutions.ExcelExtensions.csproj b/RhSolutions.ExcelExtensions/RhSolutions.ExcelExtensions.csproj
deleted file mode 100644
index bf58d4f..0000000
--- a/RhSolutions.ExcelExtensions/RhSolutions.ExcelExtensions.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <PropertyGroup>
- <TargetFrameworks>net472;net6.0-windows7.0</TargetFrameworks>
- <LangVersion>10</LangVersion>
- <ImplicitUsings>enable</ImplicitUsings>
- <Nullable>enable</Nullable>
- </PropertyGroup>
-
- <ItemGroup>
- <PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
- <PackageReference Include="System.Net.Http" Version="4.3.4" />
- </ItemGroup>
-
-</Project>
diff --git a/RhSolutions.ExcelExtensions/Row.cs b/RhSolutions.ExcelExtensions/Row.cs
deleted file mode 100644
index 01df2e4..0000000
--- a/RhSolutions.ExcelExtensions/Row.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-namespace RhSolutions.ExcelExtensions;
-
-public sealed class Row
-{
- public Table ParentTable { get; }
- public int Index
- {
- get => _range.Row - ParentTable.Range.Row;
- }
- public int Length
- {
- get => _range.Columns.Count;
- }
- private readonly Cell[] _cells;
- private readonly Range _range;
-
- public Row(Range range, Table table)
- {
- _cells = new Cell[range.Columns.Count];
- _range = range;
- ParentTable = table ??
- throw new ArgumentNullException("table");
- }
-
- public Cell this[int index]
- {
- get
- {
- if (index < 0 || index >= Length)
- {
- throw new IndexOutOfRangeException();
- }
-
- if (_cells[index] == null)
- {
- _cells[index] = new Cell(_range.Cells[1, index + 1], ParentTable);
- return _cells[index];
- }
- else
- {
- return _cells[index];
- }
- }
- }
-
- public Cell this[string header]
- {
- get
- {
- int columnIndex = ParentTable.ColumnByHeader(header).Index;
- return this[columnIndex];
- }
- }
-}
diff --git a/RhSolutions.ExcelExtensions/Rows.cs b/RhSolutions.ExcelExtensions/Rows.cs
deleted file mode 100644
index c6d4c01..0000000
--- a/RhSolutions.ExcelExtensions/Rows.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections;
-
-namespace RhSolutions.ExcelExtensions;
-
-public class Rows : IEnumerable<Row>
-{
- public Table ParentTable { get; }
- public int Length
- {
- get => _range.Rows.Count;
- }
- private Row[] _rows;
- private Range _range;
-
- public Rows(Table parentTable)
- {
- ParentTable = parentTable;
- _range = parentTable.Range;
- _rows = new Row[Length];
- }
-
- public Row this[int index]
- {
- get
- {
- if (_rows[index] == null)
- {
- _rows[index] = new Row(_range.Rows[index + 1], ParentTable);
- return _rows[index];
- }
- else
- {
- return _rows[index];
- }
- }
- }
-
- public IEnumerator<Row> GetEnumerator()
- {
- return new RowsEnumerator(this);
- }
-
- IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
-}
diff --git a/RhSolutions.ExcelExtensions/RowsEnumerator.cs b/RhSolutions.ExcelExtensions/RowsEnumerator.cs
deleted file mode 100644
index 4d68a9c..0000000
--- a/RhSolutions.ExcelExtensions/RowsEnumerator.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Collections;
-
-namespace RhSolutions.ExcelExtensions;
-
-public class RowsEnumerator : IEnumerator<Row>
-{
- private Rows _rows;
- private int position = -1;
- object IEnumerator.Current
- {
- get
- {
- return Current;
- }
- }
-
- public Row Current
- {
- get
- {
- try
- {
- return _rows[position];
- }
- catch (IndexOutOfRangeException)
- {
- throw new InvalidOperationException();
- }
- }
- }
-
- public RowsEnumerator(Rows rows)
- {
- _rows = rows;
- }
-
- public bool MoveNext()
- {
- position++;
- return (position < _rows.Length);
- }
-
- public void Reset()
- {
- position = -1;
- }
-
- public void Dispose()
- {
-
- }
-} \ No newline at end of file
diff --git a/RhSolutions.ExcelExtensions/Table.cs b/RhSolutions.ExcelExtensions/Table.cs
deleted file mode 100644
index aad2151..0000000
--- a/RhSolutions.ExcelExtensions/Table.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-namespace RhSolutions.ExcelExtensions;
-
-public class Table
-{
- public Range Range { get; protected set; }
- public Table ParentTable { get; protected set; }
- public Rows Rows { get; }
- public Columns Columns { get; }
- private Dictionary<string, Column> _columnsByHeader;
-
- public Table(Range range)
- {
- Range = range;
- ParentTable = this;
- Rows = new Rows(this);
- Columns = new Columns(this);
- _columnsByHeader = new();
-
- foreach(var column in Columns)
- {
- if (_columnsByHeader.ContainsKey(column.Header))
- {
- throw new ArgumentException($"Заголовок столбца {column.Header} не уникален");
- }
- else
- {
- _columnsByHeader.Add(column.Header, column);
- }
- }
- }
-
- public Column ColumnByHeader(string header)
- {
- return _columnsByHeader[header];
- }
-
- public Cell this[int row, int column]
- {
- get => this.Rows[row][column];
- }
-
- public IEnumerable<Cell> Search(object item)
- {
- Range firstFound = Range.Find(item);
- if (firstFound == null)
- {
- yield break;
- }
-
- Range nextFound = firstFound;
-
- while (true)
- {
- yield return this[nextFound.Row - ParentTable.Range.Row, nextFound.Column - ParentTable.Range.Column];
- nextFound = Range.FindNext(nextFound);
-
- if (nextFound.Row == firstFound.Row
- && nextFound.Column == firstFound.Column)
- {
- yield break;
- }
- }
- }
-}
diff --git a/RhSolutions.ExcelExtensions/Usings.cs b/RhSolutions.ExcelExtensions/Usings.cs
deleted file mode 100644
index 94bcc5e..0000000
--- a/RhSolutions.ExcelExtensions/Usings.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-global using Microsoft.Office.Interop.Excel;
-global using System.Collections.Generic;
-global using Range = Microsoft.Office.Interop.Excel.Range; \ No newline at end of file