Skip to content

Commit 2731222

Browse files
committed
test: 特殊符号
1 parent 1cd7506 commit 2731222

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29+
<None Update="ExcelDir\test.person.special-char.xlsx">
30+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
31+
</None>
2932
<None Update="ExcelDir\test-issue32-skipline.xlsx">
3033
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3134
</None>
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Chsword.Excel2Object.Tests.Models;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Newtonsoft.Json;
4+
using System;
5+
using System.Linq;
6+
7+
namespace Chsword.Excel2Object.Tests;
8+
[TestClass]
9+
public class Issue37SpecialCharTest : BaseExcelTest
10+
{
11+
[TestMethod]
12+
public void SpecialCharTest()
13+
{
14+
var path = GetLocalFilePath("test.person.special-char.xlsx");
15+
var importer = new ExcelImporter();
16+
var result = importer.ExcelToObject<TestModelPersonSpecialChar>(path)!.ToList();
17+
Assert.AreEqual(2, result.Count);
18+
Assert.AreEqual("100", result[0].Money);
19+
Assert.AreEqual("200", result[1].Money);
20+
Console.WriteLine(JsonConvert.SerializeObject(result));
21+
}
22+
23+
[ExcelTitle("Test Person")]
24+
class TestModelPersonSpecialChar
25+
{
26+
[ExcelTitle("姓名$")] public string Name { get; set; }
27+
[ExcelTitle("$年龄")] public int? Age { get; set; }
28+
[ExcelTitle("出生日期#")] public DateTime? Birthday { get; set; }
29+
[ExcelTitle("金额$")] public string Money { get; set; }
30+
}
31+
}

Chsword.Excel2Object/Chsword.Excel2Object.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Product>Chsword.Excel2Object Library</Product>
1111
<Authors>Zou Jian</Authors>
1212
<Version>2.0.0</Version>
13-
<Copyright>Copyright © 2014-2020</Copyright>
13+
<Copyright>Copyright © 2014-2023</Copyright>
1414
<PackageProjectUrl>https://github.com/chsword/Excel2Object/</PackageProjectUrl>
1515
<PackageReadmeFile>README.md</PackageReadmeFile>
1616
<PackageTags>excel,.net,netcore</PackageTags>

0 commit comments

Comments
 (0)