mini-software / MiniExcel

Fast, Low-Memory, Easy Excel .NET helper to import/export/template spreadsheet (support Linux, Mac)
https://www.nuget.org/packages/MiniExcel/
Apache License 2.0
2.66k stars 325 forks source link

IEnumerable 数据填充模板时,如果数据类型中包含枚举,则渲染生成的xlsx文件Excel会提示部分内容有问题 #527

Open elvisw opened 1 year ago

elvisw commented 1 year ago

Excel Type

Upload Excel File

Please attach your issue file by dragging or droppng, selecting or pasting them.

e.g : https://github.com/shps951023/MiniExcel/files/6538107/demo.xlsx

MiniExcel Version

1.31.2

Description

IEnumerable 数据填充模板时,如果数据类型中包含枚举,则渲染生成的xlsx文件Excel会提示部分内容有问题。 测试用例源码如下(LinqPad C# Statements):

var row = new List<Dto>()
{
new Dto() {Name = "Bill",UserType = Type.V1},
new Dto() {Name = "Bob",UserType = Type.V2}
};
var value = new { t = row };
MiniExcel.SaveAsByTemplate(@"C:\Users\User\Desktop\测试\MiniExcel\result.xlsx", @"C:\Users\User\Desktop\测试\MiniExcel\template.xlsx", value);

public class Dto
{
    public string Name { get; set; }
    public Type UserType { get; set; }
}

public enum Type
{
    [Description("General User")]
    V1,
    [Description("General Administrator")]
    V2,
    [Description("Super Administrator")]
    V3
}

渲染模板: template.xlsx 运行结果: result.xlsx

用Excel打开运行结果,出现如下提示:

1 2

XML文件内容如下: error242080_01.zip

elvisw commented 1 year ago

而且我发现渲染的结果也没有使用Description特性标注的值