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

空指针异常 #549

Open
5 tasks
Farb opened this issue Jan 24, 2024 · 0 comments
Open
5 tasks

空指针异常 #549

Farb opened this issue Jan 24, 2024 · 0 comments

Comments

@Farb
Copy link

Farb commented Jan 24, 2024

Expected behaviour

即使缺少列名,也不应该报错空指针,而应该给出具体的错误。当前不使用源码调试的话,根本不知道哪里的问题

Actual behaviour

image

Tell us what happens instead. Provide a log message if relevant.
导入excel时,实体类的字段在excel中少一个字段

I'm seeing this behaviour on

  • [ x] Magicodes.IE.Excel
  • Magicodes.IE.Pdf
  • Magicodes.IE.Word
  • Magicodes.IE.Csv
  • Magicodes.IE.Html
  • Magicodes.IE.AspNetCore

package versions

PackageReference Include="Magicodes.IE.Excel" Version="2.7.4.5"

So how can we reproduce this?

导入excel时,实体类的字段在excel中少一个字段

Awesome ⭐⭐⭐⭐⭐

Provide a (link to a) minimal demo app showing the faulty behaviour.

Sweet ⭐⭐⭐⭐

Provide a concise code sample which can upload attachments.
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "Import", "班级学生基础数据导入.xlsx"); 文件sheet中的第一个列删除,然后运行以下测试用例即可复现。

      [Fact(DisplayName = "班级学生基础数据导入")]
      public async Task ClassStudentInfoImporter_Test()
      {
          var filePath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "Import", "班级学生基础数据导入.xlsx");
          var importDic = await Importer.ImportSameSheets<ImportClassStudentDto, ImportStudentDto>(filePath);
          foreach (var item in importDic)
          {
              var import = item.Value;
              import.ShouldNotBeNull();
              if (import.Exception != null) _testOutputHelper.WriteLine(import.Exception.ToString());
              if (import.RowErrors.Count > 0)
                  _testOutputHelper.WriteLine(JsonConvert.SerializeObject(import.RowErrors));
              import.HasError.ShouldBeFalse();
              import.Data.ShouldNotBeNull();
              import.Data.Count.ShouldBe(16);
          }
      }

Good ⭐⭐⭐

Provide your own app and instructions how to reproduce the issue.

Meh ⭐⭐

Provide a code sample with a bunch of magic parameters which I need to interpolate by guessing to reconstruct the actual runtime code.

Worst 💩

Say the source code can't be disclosed and refuse to provide any of the above. Expect this issue to be closed by a bunch of angry aliens 👽👽👽👽👽 that will hunt you down and 🔥 your 💻. You've been warned. 🚒

hueifeng added a commit that referenced this issue Feb 1, 2024
#549-Excel中缺少列时,应返回空和错误,不应该空指针异常
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant