From 47f1805cecf86f95b87c88b7674295489a5fa7bf Mon Sep 17 00:00:00 2001 From: Shane32 Date: Tue, 23 Aug 2022 09:27:18 -0400 Subject: [PATCH 1/5] Support .NET Framework --- .../Shane32.ExcelLinq.Tests.csproj | 4 ++-- src/Shane32.ExcelLinq.Tests/Writing/OnWriteFile.cs | 1 + src/Shane32.ExcelLinq/ExcelContext.cs | 12 ++++++++---- src/Shane32.ExcelLinq/Shane32.ExcelLinq.csproj | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj b/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj index 9d5b2e1..edde9ea 100644 --- a/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj +++ b/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net48 diff --git a/src/Shane32.ExcelLinq.Tests/Writing/OnWriteFile.cs b/src/Shane32.ExcelLinq.Tests/Writing/OnWriteFile.cs index cee65fe..0de7cdb 100644 --- a/src/Shane32.ExcelLinq.Tests/Writing/OnWriteFile.cs +++ b/src/Shane32.ExcelLinq.Tests/Writing/OnWriteFile.cs @@ -17,6 +17,7 @@ public class OnWriteFile public void Multiple() { var package = new ExcelPackage(); + package.Compatibility.IsWorksheets1Based = false; var workbook = package.Workbook; var mock = new Mock(); mock.CallBase = true; diff --git a/src/Shane32.ExcelLinq/ExcelContext.cs b/src/Shane32.ExcelLinq/ExcelContext.cs index d951ef2..28da3e1 100644 --- a/src/Shane32.ExcelLinq/ExcelContext.cs +++ b/src/Shane32.ExcelLinq/ExcelContext.cs @@ -63,6 +63,7 @@ protected ExcelContext(string filename) : this() { using var stream = new FileStream(filename ?? throw new ArgumentNullException(nameof(filename)), FileMode.Open, FileAccess.Read, FileShare.Read); using var package = new ExcelPackage(stream); + package.Compatibility.IsWorksheets1Based = false; _initialized = false; _sheets = InitializeReadFile(package); _initialized = true; @@ -82,6 +83,7 @@ protected ExcelContext(Stream stream) : this() { if (stream == null) throw new ArgumentNullException(nameof(stream)); using var package = new ExcelPackage(stream); + package.Compatibility.IsWorksheets1Based = false; _initialized = false; _sheets = InitializeReadFile(package); _initialized = true; @@ -154,12 +156,13 @@ protected virtual List OnReadFile(ExcelWorkbook workbook) var sheetArray = Model.Sheets.ToList(); if (Model.IgnoreSheetNames) { - for (var i = 0; i < workbook.Worksheets.Count && i < sheetArray.Count; i++) { - var worksheet = workbook.Worksheets[i]; + int i = 0; + foreach (var worksheet in workbook.Worksheets) { var sheetModel = Model.Sheets[i]; var sheetData = OnReadSheet(worksheet, sheetModel); - if (sheetData == null) throw new InvalidOperationException($"{nameof(OnReadSheet)} returned null for sheet '{sheetModel.Name}'"); - sheets[i] = sheetData; + if (sheetData == null) + throw new InvalidOperationException($"{nameof(OnReadSheet)} returned null for sheet '{sheetModel.Name}'"); + sheets[i++] = sheetData; } } else { @@ -493,6 +496,7 @@ public List GetSheet(string name) public virtual ExcelPackage SerializeToExcelPackage() { var excelPackage = new ExcelPackage(); + excelPackage.Compatibility.IsWorksheets1Based = false; OnWriteFile(excelPackage.Workbook); return excelPackage; } diff --git a/src/Shane32.ExcelLinq/Shane32.ExcelLinq.csproj b/src/Shane32.ExcelLinq/Shane32.ExcelLinq.csproj index 9f735e4..0d23902 100644 --- a/src/Shane32.ExcelLinq/Shane32.ExcelLinq.csproj +++ b/src/Shane32.ExcelLinq/Shane32.ExcelLinq.csproj @@ -6,7 +6,7 @@ - + From 6536085c47f252d38d27063377f0b9998f3f940d Mon Sep 17 00:00:00 2001 From: Shane32 Date: Tue, 23 Aug 2022 09:29:38 -0400 Subject: [PATCH 2/5] Update --- src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj b/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj index edde9ea..1576f6c 100644 --- a/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj +++ b/src/Shane32.ExcelLinq.Tests/Shane32.ExcelLinq.Tests.csproj @@ -1,7 +1,10 @@ - - netcoreapp3.1;net48 + + netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 + + + netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net462;net48 From 394d0966a2b0e0f2ed2f56f00f44fd05907d323f Mon Sep 17 00:00:00 2001 From: Shane32 Date: Tue, 23 Aug 2022 09:35:10 -0400 Subject: [PATCH 3/5] Update --- .github/workflows/build.yml | 4 ++-- .github/workflows/publish.yml | 4 ++-- .github/workflows/test.yml | 8 ++++++-- Shane32.ExcelLinq.sln | 11 +++++++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7945e0..bc878c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use .NET Core 3.1 SDK + - name: Use .NET Core 6.0 SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' + dotnet-version: '6.0.x' source-url: https://nuget.pkg.github.com/Shane32/index.json env: NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fbb3c1e..e3bf72d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,10 +23,10 @@ jobs: version="${github_ref:10}" echo version=$version echo "version=$version" >> $GITHUB_ENV - - name: Use .NET Core 3.1 SDK + - name: Use .NET Core 6.0 SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' + dotnet-version: '6.0.x' source-url: https://api.nuget.org/v3/index.json env: NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 835a99e..9ced575 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,10 +21,14 @@ jobs: steps: - name: Checkout source uses: actions/checkout@v2 - - name: Use .NET Core 3.1 LTS SDK + - name: Use .NET Core SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' + dotnet-version: + - 2.1.x + - 3.1.x + - 5.0.x + - 6.0.x source-url: https://nuget.pkg.github.com/Shane32/index.json env: NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/Shane32.ExcelLinq.sln b/Shane32.ExcelLinq.sln index b4c6372..51962f3 100644 --- a/Shane32.ExcelLinq.sln +++ b/Shane32.ExcelLinq.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32811.315 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{B194B3FB-53C8-4C5D-ABC3-EAB6A52C674D}" ProjectSection(SolutionItems) = preProject @@ -18,6 +18,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shane32.ExcelLinq", "src\Sh EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shane32.ExcelLinq.Tests", "src\Shane32.ExcelLinq.Tests\Shane32.ExcelLinq.Tests.csproj", "{83E2AC89-22B4-438D-92CF-FDA280B63CFD}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{1D410362-3E9F-4ABF-B537-D9980F1452F6}" + ProjectSection(SolutionItems) = preProject + .github\workflows\build.yml = .github\workflows\build.yml + .github\workflows\publish.yml = .github\workflows\publish.yml + .github\workflows\test.yml = .github\workflows\test.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From ca740622bfd2c9d6535ca65e4cbdff71e685fe9a Mon Sep 17 00:00:00 2001 From: Shane32 Date: Tue, 23 Aug 2022 09:41:39 -0400 Subject: [PATCH 4/5] Update --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ced575..0d31a1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,11 +24,11 @@ jobs: - name: Use .NET Core SDK uses: actions/setup-dotnet@v1 with: - dotnet-version: - - 2.1.x - - 3.1.x - - 5.0.x - - 6.0.x + dotnet-version: | + 2.1.x + 3.1.x + 5.0.x + 6.0.x source-url: https://nuget.pkg.github.com/Shane32/index.json env: NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} From b245a8ea4e3d9e1ae0e94363cef24126743d6aa0 Mon Sep 17 00:00:00 2001 From: Shane32 Date: Tue, 23 Aug 2022 09:48:06 -0400 Subject: [PATCH 5/5] Update --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d31a1d..c1b2dab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,7 @@ jobs: if: ${{ matrix.os == 'ubuntu-latest' }} uses: danielpalme/ReportGenerator-GitHub-Action@4.7.1 with: - reports: '${{ matrix.os }}.lcov.info' + reports: '${{ matrix.os }}.lcov.net6.0.info' targetdir: '.' reporttypes: 'Clover;HtmlSummary' tag: 'test_${{ github.run_number }}' @@ -53,7 +53,7 @@ jobs: if: ${{ matrix.os == 'ubuntu-latest' }} uses: danielpalme/ReportGenerator-GitHub-Action@4.7.1 with: - reports: '${{ matrix.os }}.lcov.info' + reports: '${{ matrix.os }}.lcov.net6.0.info' targetdir: './cloverreport' reporttypes: 'Html' tag: 'test_${{ github.run_number }}' @@ -62,7 +62,7 @@ jobs: with: name: Code coverage artifacts path: | - ${{ matrix.os }}.lcov.info + ${{ matrix.os }}.lcov.* Clover.xml cloverreport/** summary.html @@ -80,14 +80,14 @@ jobs: uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{secrets.GITHUB_TOKEN }} - path-to-lcov: ${{ matrix.os }}.lcov.info + path-to-lcov: ${{ matrix.os }}.lcov.net6.0.info parallel: true flag-name: ${{ matrix.os }} - name: Upload coverage to Codecov if: ${{ 0 == 1 }} uses: codecov/codecov-action@v1 with: - file: ${{ matrix.os }}.lcov.info + file: ${{ matrix.os }}.lcov.net6.0.info flags: unittests # optional name: codecov-umbrella # optional fail_ci_if_error: true # optional (default = false)