Skip to content

Commit

Permalink
Updated to support version 22.1.1 (#6)
Browse files Browse the repository at this point in the history
* Updated to support version 22.1.1

* Updated parser to handle blank rows

* Fixed #4

* Fixed #5

* Updated builds

* Updated to support netstandard2.0
  • Loading branch information
youngcm2 authored Feb 9, 2021
1 parent f2a0235 commit bf12797
Show file tree
Hide file tree
Showing 35 changed files with 1,174 additions and 806 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: .NET Publish

on:
push:
branches: [ main, release/* ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore ./src/CsvHelper.Excel.sln
- name: Build
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
- name: Pack
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .
- name: PushNuget
run: dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate

27 changes: 19 additions & 8 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: .NET
name: .NET CI

on:
push:
branches: [ master, release/* ]
on:
pull_request:
branches: [ master, release/* ]
types: [opened]

jobs:
build:
Expand All @@ -13,13 +11,26 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
run: dotnet restore ./src/CsvHelper.Excel.sln
- name: Build
run: dotnet build --no-restore
run: dotnet build --no-restore --configuration Release ./src/CsvHelper.Excel.sln
- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test --no-build --configuration Release --verbosity normal ./src/CsvHelper.Excel.sln
- name: Pack
run: dotnet pack --no-build --configuration Release --version-suffix="${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}" ./src/CsvHelper.Excel/CsvHelper.Excel.csproj --output .

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ project.lock.json
/**/.idea
/src/packages
/src/CsvHelper.Excel.userprefs
src/CsvHelper.Excel/nupkg
*.nupkg
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet-core 5.0.104
8 changes: 8 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
assembly-versioning-scheme: MajorMinorPatch
mode: Mainline
branches:
master:
regex: (^master$|^origin\/master$|^main$|^origin\/main$)
release:
tag: beta
mode: ContinuousDeployment
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ var people = reader.GetRecords<Person>();

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

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

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.
```csharp
using (var writer = new CsvWriter(new ExcelSerializer("path/to/file.xlsx")))
using (var writer = new ExcelWriter("path/to/file.xlsx"))
{
writer.WriteRecords(people);
}
Expand All @@ -46,10 +46,14 @@ When an instance of `stream` is passed to the constructor the creation and dispo
```csharp

using var stream = new MemoryStream();
using var serialiser = new ExcelParser(stream);
using var writer = new CsvWriter(serialiser);
writer.WriteRecords(people);
using (var excelWriter = new ExcelWriter(stream, CultureInfo.InvariantCulture))
{
excelWriter.WriteRecords(people);
}
//has to be disposed to write to the stream before accessing it.
//other stuff
var bytes = stream.ToArray();
```
All constructor options have overloads allowing you to specify your own `CsvConfiguration`, otherwise the default is used.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using ClosedXML.Excel;

namespace CsvHelper.Excel.Specs
namespace CsvHelper.Excel.Specs.Common
{
public static class Helpers
{
Expand Down Expand Up @@ -29,7 +29,7 @@ public static IXLWorksheet GetOrAddWorksheet(this XLWorkbook workbook, string sh
public static void Delete(string path)
{
var directory = Path.GetDirectoryName(path);
Directory.Delete(directory, true);
Directory.Delete(directory!, true);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

namespace CsvHelper.Excel.Specs
namespace CsvHelper.Excel.Specs.Common
{
public class Person
{
Expand Down
16 changes: 9 additions & 7 deletions src/CsvHelper.Excel.Specs/CsvHelper.Excel.Specs.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.95.3" />
<PackageReference Include="CsvHelper" Version="15.0.5" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.11.3" />
<PackageReference Include="ClosedXML" Version="0.95.4" />
<PackageReference Include="CsvHelper" Version="22.1.1" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.12.1" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.7.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.8.3" />
<PackageReference Include="System.Linq.Async" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
147 changes: 0 additions & 147 deletions src/CsvHelper.Excel.Specs/ExcelParserSpecs.cs

This file was deleted.

Loading

0 comments on commit bf12797

Please sign in to comment.