Skip to content

Commit 8d616af

Browse files
Merge pull request #111 from IowaComputerGurus/feature/finalized-net-9
Updated Packages & Functionality
2 parents 3645e1a + 5acb9a0 commit 8d616af

File tree

11 files changed

+80
-73
lines changed

11 files changed

+80
-73
lines changed

.github/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- question
5+
- wontfix
6+
- invalid
7+
categories:
8+
- title: Exciting New Features 🎉
9+
labels:
10+
- enhancement
11+
- feature
12+
- title: Squashed Bugs 🐛
13+
labels:
14+
- bug
15+
- breaking-change
16+
- title: Administrative
17+
labels:
18+
- administrative
19+
- documentation
20+
- dependencies
21+
- title: Other Changes
22+
labels:
23+
- "*"

.github/workflows/ci-build.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ jobs:
2424
dotnet-version: 9.0.x
2525

2626
- name: Install GitVersion
27-
uses: gittools/actions/gitversion/setup@v3.2.1
27+
uses: gittools/actions/gitversion/setup@v4.2.0
2828
with:
29-
versionSpec: '6.0.5'
30-
29+
versionSpec: '6.4.0'
30+
3131
- name: Determine Version
3232
id: gitversion
33-
uses: gittools/actions/gitversion/[email protected]
34-
with:
35-
useConfigFile: true
33+
uses: gittools/actions/gitversion/[email protected]
3634

3735
- name: Restore Packages
3836
run: dotnet restore "${{ env.solution-path }}"
@@ -81,24 +79,22 @@ jobs:
8179
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
8280
8381
- name: Install GitVersion
84-
uses: gittools/actions/gitversion/setup@v3.2.1
82+
uses: gittools/actions/gitversion/setup@v4.2.0
8583
with:
86-
versionSpec: '6.0.5'
84+
versionSpec: '6.4.0'
8785

8886
- name: Determine Version
8987
id: gitversion
90-
uses: gittools/actions/gitversion/[email protected]
91-
with:
92-
useConfigFile: true
88+
uses: gittools/actions/gitversion/[email protected]
9389

9490
- name: Build and analyze
9591
env:
9692
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
9793
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
9894
shell: powershell
9995
run: |
100-
.\.sonar\scanner\dotnet-sonarscanner begin /k:"IowaComputerGurus_netcore.utilities.spreadsheet" /o:"iowacomputergurus-github" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
96+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"IowaComputerGurus_netcore.utilities.spreadsheet" /o:"iowacomputergurus-github" /d:sonar.token="${{ env.SONAR_TOKEN }}"
10197
dotnet restore "${{ env.solution-path }}"
10298
dotnet build "${{ env.solution-path }}" --no-restore --configuration Release -p:version=${{ steps.gitversion.outputs.majorMinorPatch }}
10399
dotnet test "${{ env.solution-path }}" --no-build --configuration Release --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --logger "trx;LogFileName=unittests.trx"
104-
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
100+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ env.SONAR_TOKEN }}"

.github/workflows/release-build.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ jobs:
2323
dotnet-version: 9.0.x
2424

2525
- name: Install GitVersion
26-
uses: gittools/actions/gitversion/setup@v3.2.1
26+
uses: gittools/actions/gitversion/setup@v4.2.0
2727
with:
28-
versionSpec: '6.0.5'
29-
28+
versionSpec: '6.4.0'
29+
3030
- name: Determine Version
3131
id: gitversion
32-
uses: gittools/actions/gitversion/[email protected]
33-
with:
34-
useConfigFile: true
32+
uses: gittools/actions/gitversion/[email protected]
3533

3634
- name: Restore Packages
3735
run: dotnet restore "${{ env.solution-path }}"

GitVersion.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ branches:
1717
pull-request:
1818
regex: (pull|pull\-requests|pr)[/-]
1919
label: 'pr'
20-
label-number-pattern: '[/-](?<number>\d+)[-/]'
2120
increment: Patch
2221
is-release-branch: false
2322
source-branches: []

samples/NetCore.Utilities.SpreadsheetExample/NetCore.Utilities.SpreadsheetExample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="DocumentFOrmat.OpenXml" Version="2.16.0" />
9+
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
1010
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
1111
</ItemGroup>
1212

src/NetCore.Utilities.Spreadsheet.Tests/NetCore.Utilities.Spreadsheet.Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Bogus" Version="34.0.2" />
11-
<PackageReference Include="coverlet.collector" Version="3.1.2">
10+
<PackageReference Include="Bogus" Version="35.6.5" />
11+
<PackageReference Include="coverlet.collector" Version="6.0.4">
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
15-
<PackageReference Include="FluentAssertions" Version="6.7.0" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
17-
<PackageReference Include="xunit" Version="2.4.1" />
18-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
15+
<PackageReference Include="FluentAssertions" Version="8.8.0" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
17+
<PackageReference Include="xunit" Version="2.9.3" />
18+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1919
<PrivateAssets>all</PrivateAssets>
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2121
</PackageReference>

src/NetCore.Utilities.Spreadsheet/NetCore.Utilities.Spreadsheet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="DocumentFormat.OpenXml" Version="2.16.0" />
37+
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
3838
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
39-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
39+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
4040
<PrivateAssets>all</PrivateAssets>
4141
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4242
</PackageReference>

src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public bool CreateSingleSheetSpreadsheet<T>(Stream output, SpreadsheetConfigurat
4646
nameof(exportConfiguration.DocumentSubTitle));
4747

4848
//Create the document & overall workbook
49-
var spreadsheetDocument = SpreadsheetDocument.Create(output, SpreadsheetDocumentType.Workbook);
49+
using var spreadsheetDocument = SpreadsheetDocument.Create(output, SpreadsheetDocumentType.Workbook);
5050

5151
var workbookPart = spreadsheetDocument.AddWorkbookPart();
5252
workbookPart.Workbook = new Workbook();
@@ -87,7 +87,6 @@ public bool CreateSingleSheetSpreadsheet<T>(Stream output, SpreadsheetConfigurat
8787
sheets.Append(sheet);
8888

8989
workbookPart.Workbook.Save();
90-
spreadsheetDocument.Close();
9190
return true;
9291

9392
}
@@ -157,10 +156,10 @@ public bool CreateMultiSheetSpreadsheet(Stream output, IEnumerable<ISpreadsheetC
157156
throw new ArgumentNullException(nameof(exportSheets));
158157

159158
//Create the document & overall workbook
160-
var spreadsheetDocument = SpreadsheetDocument.Create(output, SpreadsheetDocumentType.Workbook);
159+
using var spreadsheetDocument = SpreadsheetDocument.Create(output, SpreadsheetDocumentType.Workbook);
161160
var workbookPart = spreadsheetDocument.AddWorkbookPart();
162161
workbookPart.Workbook = new Workbook();
163-
var sheets = spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
162+
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
164163

165164
//Setup our styles
166165
var stylesPart = spreadsheetDocument.WorkbookPart.AddNewPart<WorkbookStylesPart>();
@@ -199,9 +198,9 @@ public bool CreateMultiSheetSpreadsheet(Stream output, IEnumerable<ISpreadsheetC
199198
sheets.Append(sheet);
200199
sheetId++;
201200
}
201+
202202
//Save off the file
203203
workbookPart.Workbook.Save();
204-
spreadsheetDocument.Close();
205204

206205
return true;
207206
}

src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetParser.cs

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -155,42 +155,39 @@ _ when IsOfType<DateTimeOffset>(propertyType) => DateTimeOffset.Parse(value),
155155
return cell.InnerText;
156156

157157
string value = cell.InnerText;
158-
switch (cell.DataType.Value)
158+
if (cell.DataType.Value == CellValues.SharedString)
159159
{
160-
case CellValues.SharedString:
161-
// For shared strings, look up the value in the shared strings table.
162-
// Get worksheet from cell
163-
Debug.Assert(cell.Parent != null, "cell.Parent != null");
164-
OpenXmlElement parent = cell.Parent;
165-
while (parent.Parent != null && parent.Parent != parent
166-
&& string.Compare(parent.LocalName, "worksheet", StringComparison.OrdinalIgnoreCase) != 0)
167-
{
168-
parent = parent.Parent;
169-
}
170-
if (string.Compare(parent.LocalName, "worksheet", StringComparison.OrdinalIgnoreCase) != 0)
171-
{
172-
throw new SpreadsheetParserException($"Unable to find parent worksheet of cell {cell}");
173-
}
160+
// For shared strings, look up the value in the shared strings table.
161+
// Get worksheet from cell
162+
Debug.Assert(cell.Parent != null, "cell.Parent != null");
163+
OpenXmlElement parent = cell.Parent;
164+
while (parent.Parent != null && parent.Parent != parent
165+
&& string.Compare(parent.LocalName, "worksheet", StringComparison.OrdinalIgnoreCase) != 0)
166+
{
167+
parent = parent.Parent;
168+
}
169+
if (string.Compare(parent.LocalName, "worksheet", StringComparison.OrdinalIgnoreCase) != 0)
170+
{
171+
throw new SpreadsheetParserException($"Unable to find parent worksheet of cell {cell}");
172+
}
174173

175-
var ws = parent as Worksheet;
176-
var ssDoc = ws?.WorksheetPart?.OpenXmlPackage as SpreadsheetDocument;
177-
var sstPart = ssDoc?.WorkbookPart?.GetPartsOfType<SharedStringTablePart>().FirstOrDefault();
174+
var ws = parent as Worksheet;
175+
var ssDoc = ws?.WorksheetPart?.OpenXmlPackage as SpreadsheetDocument;
176+
var sstPart = ssDoc?.WorkbookPart?.GetPartsOfType<SharedStringTablePart>().FirstOrDefault();
178177

179-
return sstPart == null ? value : sstPart.SharedStringTable.ElementAt(int.Parse(value)).InnerText;
180-
//this case within a case is copied from msdn.
181-
case CellValues.Boolean:
182-
return value switch
183-
{
184-
"0" => "FALSE",
185-
_ => "TRUE"
186-
};
187-
case CellValues.Number:
188-
case CellValues.Error:
189-
case CellValues.String:
190-
case CellValues.InlineString:
191-
case CellValues.Date:
192-
default:
193-
return value;
178+
return sstPart == null ? value : sstPart.SharedStringTable.ElementAt(int.Parse(value)).InnerText;
194179
}
180+
181+
if (cell.DataType.Value == CellValues.Boolean)
182+
{
183+
return value switch
184+
{
185+
"0" => "FALSE",
186+
_ => "TRUE"
187+
};
188+
}
189+
190+
//All other types return the value
191+
return value;
195192
}
196193
}

src/NetCore.Utilities.Spreadsheet/SpreadsheetColumnAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class SpreadsheetColumnAttribute : Attribute
1818
/// <param name="width">Sets the width of the column</param>
1919
/// <param name="ignore">If true, the column will be excluded from the spreadsheet</param>
2020
/// <param name="format">Sets the format of the column data</param>
21+
/// <param name="formula">Sets a specific formula to be utilized by this column</param>
2122
public SpreadsheetColumnAttribute(string displayName = null, float width = 0, bool ignore = false,
2223
string format = null, string formula = null)
2324
{

0 commit comments

Comments
 (0)