Skip to content

Commit bf12797

Browse files
authored
Updated to support version 22.1.1 (#6)
* Updated to support version 22.1.1 * Updated parser to handle blank rows * Fixed #4 * Fixed #5 * Updated builds * Updated to support netstandard2.0
1 parent f2a0235 commit bf12797

35 files changed

+1174
-806
lines changed

.github/workflows/dotnet-publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: .NET Publish
2+
3+
on:
4+
push:
5+
branches: [ main, release/* ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
ref: ${{ github.event.pull_request.head.sha }}
17+
- name: Install GitVersion
18+
uses: gittools/actions/gitversion/[email protected]
19+
with:
20+
versionSpec: '5.x'
21+
- name: Determine Version
22+
id: gitversion
23+
uses: gittools/actions/gitversion/[email protected]
24+
with:
25+
useConfigFile: true
26+
- name: Setup .NET
27+
uses: actions/setup-dotnet@v1
28+
with:
29+
dotnet-version: 5.0.x
30+
- name: Restore dependencies
31+
run: dotnet restore ./src/CsvHelper.Excel.sln
32+
- name: Build
33+
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
34+
- name: Test
35+
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
36+
- name: Pack
37+
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .
38+
- name: PushNuget
39+
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate
40+

.github/workflows/dotnet.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
name: .NET
1+
name: .NET CI
22

3-
on:
4-
push:
5-
branches: [ master, release/* ]
3+
on:
64
pull_request:
7-
branches: [ master, release/* ]
5+
types: [opened]
86

97
jobs:
108
build:
@@ -13,13 +11,26 @@ jobs:
1311

1412
steps:
1513
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
ref: ${{ github.event.pull_request.head.sha }}
17+
- name: Install GitVersion
18+
uses: gittools/actions/gitversion/[email protected]
19+
with:
20+
versionSpec: '5.x'
21+
- name: Determine Version
22+
id: gitversion
23+
uses: gittools/actions/gitversion/[email protected]
1624
- name: Setup .NET
1725
uses: actions/setup-dotnet@v1
1826
with:
1927
dotnet-version: 5.0.x
2028
- name: Restore dependencies
21-
run: dotnet restore
29+
run: dotnet restore ./src/CsvHelper.Excel.sln
2230
- name: Build
23-
run: dotnet build --no-restore
31+
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
2432
- name: Test
25-
run: dotnet test --no-build --verbosity normal
33+
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
34+
- name: Pack
35+
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .
36+

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ project.lock.json
88
/**/.idea
99
/src/packages
1010
/src/CsvHelper.Excel.userprefs
11-
src/CsvHelper.Excel/nupkg
11+
*.nupkg

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dotnet-core 5.0.104

GitVersion.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
assembly-versioning-scheme: MajorMinorPatch
2+
mode: Mainline
3+
branches:
4+
master:
5+
regex: (^master$|^origin\/master$|^main$|^origin\/main$)
6+
release:
7+
tag: beta
8+
mode: ContinuousDeployment

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ var people = reader.GetRecords<Person>();
3232

3333
All constructor options have overloads allowing you to specify your own `CsvConfiguration`, otherwise the default is used.
3434

35-
### ExcelSerializer
36-
`ExcelSerializer` implements `ISerializer` and, like `ExcelParser`, allows you to specify the path to which to (eventually) save the workbook or a stream.
35+
### ExcelWriter
36+
`ExcelWriter` inherits from `CsvWriter` and, like `ExcelParser`, allows you to specify the path to which to (eventually) save the workbook or a stream.
3737

3838
When the path is passed to the constructor the creation and disposal of both the workbook and worksheet (defaultly named "Export") as well as the saving of the workbook on dispose, is handled by the serialiser.
3939
```csharp
40-
using (var writer = new CsvWriter(new ExcelSerializer("path/to/file.xlsx")))
40+
using (var writer = new ExcelWriter("path/to/file.xlsx"))
4141
{
4242
writer.WriteRecords(people);
4343
}
@@ -46,10 +46,14 @@ When an instance of `stream` is passed to the constructor the creation and dispo
4646
```csharp
4747

4848
using var stream = new MemoryStream();
49-
using var serialiser = new ExcelParser(stream);
50-
using var writer = new CsvWriter(serialiser);
51-
writer.WriteRecords(people);
49+
using (var excelWriter = new ExcelWriter(stream, CultureInfo.InvariantCulture))
50+
{
51+
excelWriter.WriteRecords(people);
52+
}
53+
//has to be disposed to write to the stream before accessing it.
54+
5255
//other stuff
5356
var bytes = stream.ToArray();
5457
```
5558
All constructor options have overloads allowing you to specify your own `CsvConfiguration`, otherwise the default is used.
59+

src/CsvHelper.Excel.Specs/Helpers.cs renamed to src/CsvHelper.Excel.Specs/Common/Helpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.IO;
22
using ClosedXML.Excel;
33

4-
namespace CsvHelper.Excel.Specs
4+
namespace CsvHelper.Excel.Specs.Common
55
{
66
public static class Helpers
77
{
@@ -29,7 +29,7 @@ public static IXLWorksheet GetOrAddWorksheet(this XLWorkbook workbook, string sh
2929
public static void Delete(string path)
3030
{
3131
var directory = Path.GetDirectoryName(path);
32-
Directory.Delete(directory, true);
32+
Directory.Delete(directory!, true);
3333
}
3434
}
3535
}

src/CsvHelper.Excel.Specs/Person.cs renamed to src/CsvHelper.Excel.Specs/Common/Person.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
namespace CsvHelper.Excel.Specs
2+
namespace CsvHelper.Excel.Specs.Common
33
{
44
public class Person
55
{

src/CsvHelper.Excel.Specs/CsvHelper.Excel.Specs.csproj

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFramework>net5.0</TargetFramework>
4+
<LangVersion>latest</LangVersion>
45
</PropertyGroup>
56
<ItemGroup>
6-
<PackageReference Include="ClosedXML" Version="0.95.3" />
7-
<PackageReference Include="CsvHelper" Version="15.0.5" />
8-
<PackageReference Include="DocumentFormat.OpenXml" Version="2.11.3" />
7+
<PackageReference Include="ClosedXML" Version="0.95.4" />
8+
<PackageReference Include="CsvHelper" Version="22.1.1" />
9+
<PackageReference Include="DocumentFormat.OpenXml" Version="2.12.1" />
910
<PackageReference Include="FluentAssertions" Version="5.10.3" />
10-
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
12-
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.7.0" />
11+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
13+
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.8.3" />
14+
<PackageReference Include="System.Linq.Async" Version="5.0.0" />
1315
<PackageReference Include="xunit" Version="2.4.1" />
1416
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1517
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

src/CsvHelper.Excel.Specs/ExcelParserSpecs.cs

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)