Skip to content

Commit 9a68b54

Browse files
committed
Added readme; Added LICENSE notes;
1 parent b4f2193 commit 9a68b54

File tree

6 files changed

+74
-2
lines changed

6 files changed

+74
-2
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 by Bal�zs HIDEGH�TY
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NPOI.Extensions.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NPOI.Extensions", "NPOI.Ext
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NPOI.Extensions.XUnitTest", "NPOI.Extensions.Tests\NPOI.Extensions.XUnitTest.csproj", "{26500AE4-4542-4CD9-9311-643B12A9573B}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NPOI.Extensions.Samples", "NPOI.Extensions.Samples\NPOI.Extensions.Samples.csproj", "{25A62B77-F2E9-4942-AA0D-DF5CDABED4E0}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NPOI.Extensions.Samples", "NPOI.Extensions.Samples\NPOI.Extensions.Samples.csproj", "{25A62B77-F2E9-4942-AA0D-DF5CDABED4E0}"
11+
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{7C91185C-55C9-48AF-A655-10C7A1265A36}"
13+
ProjectSection(SolutionItems) = preProject
14+
LICENSE = LICENSE
15+
readme.md = readme.md
16+
EndProjectSection
1117
EndProject
1218
Global
1319
GlobalSection(SolutionConfigurationPlatforms) = preSolution

NPOI.Extensions/GetValueExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static T GetValue<T>(this IRow row, int columnIndex)
3535
var formatter = new DataFormatter();
3636
var formattedValue = formatter.FormatCellValue(cell);
3737

38-
// replace non-breakign space with regular space
38+
// replace non-breakign space with regular space (nbsp were uses with numeric formatting)
3939
formattedValue = formattedValue.Replace(Convert.ToChar(160), ' ');
4040

4141
return (T) (object) formattedValue;

NPOI.Extensions/Utils/TypeUtilsExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace NPOI.Extensions.Utils
77
/// <summary>
88
/// Original implementation from TypeUtils.cs (ILSpy);
99
/// Some methods were changed to extension methods;
10+
/// Some additional functions were introduced;
1011
/// </summary>
1112
public static class TypeUtilsExtensions
1213
{

notes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://resources.whitesourcesoftware.com/blog-whitesource/open-source-licenses-explained
2+
https://snyk.io/blog/mit-apache-bsd-fairest-of-them-all/

readme.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# NPOI.Extensions
2+
This package is an extension to the https://github.com/tonyqus/npoi, as I found reading excel values with the basic interface a bit cumbersome.
3+
4+
> On my pet projects I used less flexible helper functions for reading excel cell values. They always adressed just the needs of a given use-case and were not tested for flexibility and corner-case cenarios.
5+
6+
**My goal with this library is to have a stable, reliable, simple (unified) way to read values from excel cell.**
7+
To ensure this, project includes unit tests for the GetValue extension method, covering most of the situations a developer might need in an enterprise solution.
8+
9+
10+
## This library currently
11+
12+
- **simplifies & unifies reading cell values into typed variables**
13+
- adds support to **map a sheet into a typed list** - *simple approach with 100% control over the mapping*
14+
15+
*NOTE:*
16+
17+
There's also a project (https://github.com/donnytian/Npoi.Mapper) which addresses mapping sheet to typed list, which requires a major change in the Map and ShouldMap function to be more widely usable (see: https://github.com/donnytian/Npoi.Mapper/issues/45).
18+
19+
## Major extension functions
20+
21+
**public T GetValue<T>(this IRow, index)**
22+
- **unifies access to cell value regardless of it's type**
23+
- allows to read into a typed output variable in a simple way
24+
- does a **safe null/blank cell access**, is able to map cell value (being it null or not) to Nullable&lt;&gt; types
25+
- allows to **read any cell as a formatted string** (the formatted content - that is shown inside the excel cell - is returned as a string)
26+
- handles reading of **formula results** into typed variable (we usually are interested in the result, not in the formula)
27+
28+
---
29+
**public List<T> MapTo<T>(this ISheet sheet, bool firstRowIsHeader, Func<ExcelRowMapper, T> rowMapper)**
30+
- **simplifies mapping the excel content into a typed list**
31+
- the rowMapperFunction allows to **get cell content by column header (title)**: rowMapper.GetValue&lt;DateTime&gt;("Order Date")
32+
33+
34+
## Getting started
35+
36+
There's a **sample project** (and sample excel workbooks) for the mappign extensions, where also the GetValue<T> is used.
37+
38+
The **XUnitTest** for the GetValueExtensions contains tests for all the functionality the GetValue<T> is intended to support.
39+
40+
## License
41+
https://opensource.org/licenses/MIT, Copyright (c) 2020 by Balázs HIDEGHÉTY
42+

0 commit comments

Comments
 (0)