Skip to content
New issue

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

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

Already on GitHub? # to your account

excel导出报错 #21

Closed
dashenxian opened this issue Jan 14, 2020 · 3 comments
Closed

excel导出报错 #21

dashenxian opened this issue Jan 14, 2020 · 3 comments
Assignees

Comments

@dashenxian
Copy link

版本:1.4.21
excel导出时,如果导出模型定义了ExporterHeader就会报错,这是反编译的报错的位置:
image

[AutoMap(typeof(Standard))]//这是automap的映射配置
[ExcelImporter(IsLabelingError = true)]//这个模型同时也用于导出模板
public class ImportExcelDto
{
        public const int MaxLength = 1024;
        /// <summary>
        /// 规程类型
        /// </summary>
        [MaxLength(MaxLength)]
        [Display(Name = "名称")]
        [ExporterHeader("名称")]
        public string Name { get; set; }
}
//导出文件
await exporter.Export("xxxx.xlsx", new List<ImportExcelDto>{new ImportExcelDto{Name="123"}});

如果模型没有定义ExporterHeader则不会报错

@dashenxian
Copy link
Author

dashenxian commented Jan 14, 2020

在模型类上添加ExcelExporter属性后问题消失,但是这样的隐藏关系也太诡异了

[AutoMap(typeof(Standard))]//这是automap的映射配置
[ExcelImporter(IsLabelingError = true)]//这个模型同时也用于导出模板
[ExcelExporter(Name = "标准")]
public class ImportExcelDto
{
        public const int MaxLength = 1024;
        /// <summary>
        /// 规程类型
        /// </summary>
        [MaxLength(MaxLength)]
        [Display(Name = "名称")]
        [ExporterHeader("名称")]
        public string Name { get; set; }
}

@xin-lai xin-lai self-assigned this Jan 16, 2020
@xin-lai
Copy link
Collaborator

xin-lai commented Jan 16, 2020

导入导出一起玩的我还没试过。晚点试试。

@xin-lai
Copy link
Collaborator

xin-lai commented Jan 16, 2020

已修复没有定义导出特性会报错的情形,具体见单元测试“ExportTestDataWithoutExcelExporter_Test”。

@xin-lai xin-lai closed this as completed Jan 16, 2020
xin-lai referenced this issue Jan 16, 2020
- 【导出】修复没有定义导出特性会报错的情形,具体见单元测试“ExportTestDataWithoutExcelExporter_Test”。问题见(<https://github.com/dotnetcore/Magicodes.IE/issues/21>)。
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants