Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExcelImport: Only first [ColumnIndex] is valid. #289

Closed
Nongzhsh opened this issue Jun 23, 2021 · 1 comment
Closed

ExcelImport: Only first [ColumnIndex] is valid. #289

Nongzhsh opened this issue Jun 23, 2021 · 1 comment
Labels
area-excel excel bug Something isn't working

Comments

@Nongzhsh
Copy link
Contributor

Nongzhsh commented Jun 23, 2021

Package: Magicodes.IE.Excel 2.5.4.3

I'm trying to debug ImportTestColumnIndex_Test

[Fact(DisplayName = "ColumnIndex测试")]

I have modified some code.
DTO like:

public class ImportTestColumnIndex
{
    [ImporterHeader(ColumnIndex = 1)]
    public string Name { get; set; }

    [ImporterHeader(Name = "年龄", ColumnIndex = 3)]
    public int? Age { get; set; }
}

Unit test code like:

[Fact(DisplayName = "ColumnIndex测试")]
public async Task ImportTestColumnIndex_Test()
{
    var filePath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "Import", "ColumnIndex导入测试.xlsx");
    var import = await Importer.Import<ImportTestColumnIndex>(filePath);
    import.HasError.ShouldBeFalse();
    import.TemplateErrors.Count.ShouldBe(0);
    import.ImporterHeaderInfos.Count.ShouldBe(2);
    import.Data.ElementAt(0).Age.ShouldBe(11);
}

Excel data:
image

----- Test Execution Summary -----
Magicodes.ExporterAndImporter.Tests.ExcelImporter_Tests.ImportTestColumnIndex_Test:
Outcome: Failed
Error Message:
Shouldly.ShouldAssertException : import.Data.ElementAt(0).Age
should be
11
but was
null
Stack Trace:
at Magicodes.ExporterAndImporter.Tests.ExcelImporter_Tests.ImportTestColumnIndex_Test() in d:\Github\Magicodes.IE\src\Magicodes.ExporterAndImporter.Tests\ExcelImporter_Tests.cs:line 884
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

Total tests: 1. Passed: 0. Failed: 1. Skipped: 0

All Age column data is null! [裂开]
image

@Nongzhsh
Copy link
Contributor Author

Oh,there is a bug when judging isColumnExist ,should be continue.

@hueifeng hueifeng added the area-excel excel label Jun 23, 2021
@xin-lai xin-lai added the bug Something isn't working label Jun 23, 2021
xl-wenqiang added a commit that referenced this issue Jun 25, 2021
xin-lai pushed a commit that referenced this issue Jun 25, 2021
Fix only first [ColumnIndex] is valid exception[#289](#289)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-excel excel bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants