From 1acaac5b87ae8e689b74cb92b53120c389625045 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 26 Jan 2022 11:25:46 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=9E=9A=E4=B8=BE=E7=B1=BB=E5=8C=85=E5=90=ABvalue?= =?UTF-8?q?=E4=B8=BA0=E7=9A=84=E6=9E=9A=E4=B8=BE=E9=A1=B9=EF=BC=8C?= =?UTF-8?q?=E5=85=81=E8=AE=B8excel=E4=B8=AD=E5=88=97=E9=99=90=E5=AE=9A?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E4=B8=BA=E7=A9=BA=E5=8F=96=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/DataCreators/SheetDataCreator.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs index 06994b4..4c22f97 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs @@ -196,9 +196,16 @@ namespace Luban.Job.Cfg.DataCreators { return null; } - if (x == null) + if (CheckDefault(x)) { - throw new InvalidExcelDataException($"枚举值不能为空"); + if (type.DefineEnum.HasZeroValueItem) + { + return new DEnum(type, "0"); + } + else + { + throw new InvalidExcelDataException($"枚举类:'{type.DefineEnum.FullName}' 没有value为0的枚举项, 不支持默认值"); + } } return new DEnum(type, x.ToString()); }