Skip to content

Commit b0e833a

Browse files
author
yunzai-gyf
committed
The most significant changes in the code are related to the reordering of import statements and minor formatting changes for better readability across multiple files. The versions of some packages have been updated in Chsword.Excel2Object.Tests.csproj and Chsword.Excel2Object.csproj. Minor changes have been made to the code logic in ExcelTest.cs, Issue39DynamicMappingTitle.cs, Issue31SuperClass.cs, and ExcelExporter.cs. The target frameworks in Chsword.Excel2Object.csproj have been updated to include net8.0 and the warning level for net6.0 and net472 has been set to 0. Null checks have been added for some variables in ExcelExporter.cs, ExcelImporter.cs, ExcelUtil.cs, and TypeConvert.cs. The type of the MappingColumnAction property has been updated in ExcelExporterOptions.cs. Some mathematical operations have been updated for better readability in ExcelColumnNameParser.cs, ExcelExporter.cs, and TypeConvert.cs.
List of changes: 1. Reordering of import statements and minor formatting changes in multiple files for better readability. 2. Updated versions of some packages in `Chsword.Excel2Object.Tests.csproj` and `Chsword.Excel2Object.csproj`. 3. Minor changes to the code logic in `ExcelTest.cs`, `Issue39DynamicMappingTitle.cs`, `Issue31SuperClass.cs`, and `ExcelExporter.cs`. 4. Updated target frameworks in `Chsword.Excel2Object.csproj` to include `net8.0` and set warning level for `net6.0` and `net472` to 0. 5. Added null checks for some variables in `ExcelExporter.cs`, `ExcelImporter.cs`, `ExcelUtil.cs`, and `TypeConvert.cs`. 6. Updated the type of the `MappingColumnAction` property in `ExcelExporterOptions.cs`. 7. Updated some mathematical operations for better readability in `ExcelColumnNameParser.cs`, `ExcelExporter.cs`, and `TypeConvert.cs`.
1 parent 9d326cd commit b0e833a

32 files changed

+119
-110
lines changed

Chsword.Excel2Object.Tests/BaseFunctionTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using System;
2-
using System.Linq.Expressions;
3-
using Chsword.Excel2Object.Functions;
1+
using Chsword.Excel2Object.Functions;
42
using Chsword.Excel2Object.Internal;
53
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using System;
5+
using System.Linq.Expressions;
66

77
namespace Chsword.Excel2Object.Tests;
88

99
public class BaseFunctionTest
1010
{
1111
protected void TestFunction(Expression<Func<ColumnCellDictionary, object>> exp, string expected)
1212
{
13-
var convert = new ExpressionConvert(new[] {"One", "Two", "Three", "Four", "Five", "Six"}, 3);
13+
var convert = new ExpressionConvert(new[] { "One", "Two", "Three", "Four", "Five", "Six" }, 3);
1414
var ret = convert.Convert(exp);
1515
Assert.AreEqual(expected, ret);
1616
}

Chsword.Excel2Object.Tests/Chsword.Excel2Object.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
15-
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
16-
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
17-
<PackageReference Include="coverlet.collector" Version="6.0.0">
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
15+
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
16+
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
17+
<PackageReference Include="coverlet.collector" Version="6.0.2">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
</PackageReference>

Chsword.Excel2Object.Tests/ExcelTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using System;
1+
using Chsword.Excel2Object.Tests.Models;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Newtonsoft.Json;
4+
using System;
25
using System.Collections.Generic;
36
using System.Data;
47
using System.IO;
58
using System.Linq;
6-
using Chsword.Excel2Object.Tests.Models;
7-
using Microsoft.VisualStudio.TestTools.UnitTesting;
8-
using Newtonsoft.Json;
99

1010
namespace Chsword.Excel2Object.Tests;
1111

@@ -20,7 +20,7 @@ public void ConvertXlsBytesTest()
2020
Assert.IsNotNull(bytes);
2121

2222
Assert.IsTrue(bytes.Length > 0);
23-
23+
2424
var importer = new ExcelImporter();
2525
var result = importer.ExcelToObject<ReportModel>(bytes).ToList();
2626
models.AreEqual(result);

Chsword.Excel2Object.Tests/ExportDateFormatTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
2-
using Chsword.Excel2Object.Tests.Models;
1+
using Chsword.Excel2Object.Tests.Models;
32
using Microsoft.VisualStudio.TestTools.UnitTesting;
4-
using System.Collections.Generic;
53
using NPOI.HSSF.UserModel;
4+
using System;
5+
using System.Collections.Generic;
66

77
namespace Chsword.Excel2Object.Tests;
88

Chsword.Excel2Object.Tests/ExpressionConvertTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq.Expressions;
4-
using Chsword.Excel2Object.Functions;
1+
using Chsword.Excel2Object.Functions;
52
using Chsword.Excel2Object.Internal;
63
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq.Expressions;
77
using static Chsword.Excel2Object.ExcelFunctions;
88

99
namespace Chsword.Excel2Object.Tests;
@@ -63,8 +63,8 @@ public void EDate()
6363
public void EDateWithColumn()
6464
{
6565
Expression<Func<Dictionary<string, ColumnValue>, object>> exp = c =>
66-
((DateTime) c["Date"]).AddMonths((int) c["Month"]);
67-
var convert = new ExpressionConvert(new[] {"Date", "Month"}, 3);
66+
((DateTime)c["Date"]).AddMonths((int)c["Month"]);
67+
var convert = new ExpressionConvert(new[] { "Date", "Month" }, 3);
6868
var ret = convert.Convert(exp);
6969
Assert.AreEqual("EDATE(A4,B4)", ret);
7070
}

Chsword.Excel2Object.Tests/Issue12FirstColumnEmptyTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
2-
using System.Linq;
31
using Chsword.Excel2Object.Tests.Models;
42
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System;
4+
using System.Linq;
55

66
namespace Chsword.Excel2Object.Tests;
77

Chsword.Excel2Object.Tests/Issue16FormulaTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
1+
using Chsword.Excel2Object.Options;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Newtonsoft.Json;
4+
using System;
25
using System.Collections.Generic;
36
using System.IO;
47
using System.Linq;
5-
using Chsword.Excel2Object.Options;
6-
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using Newtonsoft.Json;
88

99
namespace Chsword.Excel2Object.Tests;
1010

Chsword.Excel2Object.Tests/Issue31SuperClass.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using Chsword.Excel2Object.Internal;
1+
using Chsword.Excel2Object.Internal;
52
using Chsword.Excel2Object.Options;
63
using Microsoft.VisualStudio.TestTools.UnitTesting;
74
using Newtonsoft.Json;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
88

99
namespace Chsword.Excel2Object.Tests;
1010

@@ -16,9 +16,9 @@ public void CheckModelA()
1616
{
1717
var excel = TypeConvert.ConvertObjectToExcelModel(GetExcel<SubClassA>()!,
1818
new ExcelExporterOptions());
19-
19+
2020
Assert.IsNotNull(excel);
21-
21+
2222
Assert.AreEqual(1, excel.Sheets?.Count);
2323
Assert.IsNotNull(excel.Sheets);
2424
Assert.AreEqual("SuperClass", excel.Sheets[0].Title);

Chsword.Excel2Object.Tests/Issue32SkipLineImport.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using System;
2-
using System.Linq;
3-
using Chsword.Excel2Object.Tests.Models;
1+
using Chsword.Excel2Object.Tests.Models;
42
using Microsoft.VisualStudio.TestTools.UnitTesting;
53
using Newtonsoft.Json;
4+
using System;
5+
using System.Linq;
66

77
namespace Chsword.Excel2Object.Tests;
88

Chsword.Excel2Object.Tests/Issue39DynamicMappingTitle.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using Chsword.Excel2Object.Tests.Models;
1+
using Chsword.Excel2Object.Tests.Models;
42
using Microsoft.VisualStudio.TestTools.UnitTesting;
5-
using System.Linq;
63
using Newtonsoft.Json;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
77

88
namespace Chsword.Excel2Object.Tests;
99
[TestClass]
@@ -15,7 +15,7 @@ public void MappingTitle()
1515
var models = GetModels();
1616
var bytes = ExcelHelper.ObjectToExcelBytes(models, options =>
1717
{
18-
options.MappingColumnAction = (title,_) =>
18+
options.MappingColumnAction = (title, _) =>
1919
{
2020
if (title == "姓名")
2121
{
@@ -29,27 +29,27 @@ public void MappingTitle()
2929
Assert.IsTrue(bytes.Length > 0);
3030

3131
var importer = new ExcelImporter();
32-
var result = importer.ExcelToObject<Dictionary<string,object>>(bytes).ToList();
32+
var result = importer.ExcelToObject<Dictionary<string, object>>(bytes).ToList();
3333
Console.WriteLine(JsonConvert.SerializeObject(result));
34-
34+
3535
}
3636

3737
private IEnumerable<TestModelDatePerson> GetModels()
3838
{
39-
var list = new List<TestModelDatePerson>
39+
var list = new List<TestModelDatePerson>
4040
{
4141
new()
4242
{
4343
Name = "Three Zhang",
4444
Age = 18,
45-
Birthday = new DateTime(1990, 1, 1),
45+
Birthday = new DateTime(1990, 1, 1),
4646
Birthday2 = null
4747
},
4848
new()
4949
{
5050
Name = "Four Lee",
5151
Age = 18,
52-
Birthday = new DateTime(1990, 1, 1),
52+
Birthday = new DateTime(1990, 1, 1),
5353
Birthday2 = null
5454
},
5555
};

0 commit comments

Comments
 (0)