diff --git a/src/Luban.DataLoader.Builtin/DataVisitors/ExcelStreamDataCreator.cs b/src/Luban.DataLoader.Builtin/DataVisitors/ExcelStreamDataCreator.cs index 76822980..6aeb92bf 100644 --- a/src/Luban.DataLoader.Builtin/DataVisitors/ExcelStreamDataCreator.cs +++ b/src/Luban.DataLoader.Builtin/DataVisitors/ExcelStreamDataCreator.cs @@ -262,14 +262,20 @@ public DType Accept(TBean type, ExcelStream x) { if (type.IsNullable) { - string subType = x.Read().ToString().Trim(); - if (subType == FieldNames.BeanNullType) + if (x.TryPeed(out object subTypeObj)) //ToString().Trim(); { - return null; - } - else if (subType != FieldNames.BeanNotNullType && subType != originBean.Name) - { - throw new Exception($"type:'{originBean.FullName}' 可空标识:'{subType}' 不合法(只能为{FieldNames.BeanNotNullType}或{FieldNames.BeanNullType}或{originBean.Name})"); + string subType = subTypeObj.ToString().Trim(); + + if (subType == FieldNames.BeanNullType) + { + x.Read(); + return null; + } + else if (subType == FieldNames.BeanNotNullType || subType == originBean.Name) + { + x.Read(); + //throw new Exception($"type:'{originBean.FullName}' 可空标识:'{subType}' 不合法(只能为{FieldNames.BeanNotNullType}或{FieldNames.BeanNullType}或{originBean.Name})"); + } } } return new DBean(type, originBean, CreateBeanFields(originBean, x)); diff --git a/src/Luban.DataLoader.Builtin/Excel/ExcelStream.cs b/src/Luban.DataLoader.Builtin/Excel/ExcelStream.cs index 48f4d92e..d2a9f399 100644 --- a/src/Luban.DataLoader.Builtin/Excel/ExcelStream.cs +++ b/src/Luban.DataLoader.Builtin/Excel/ExcelStream.cs @@ -190,6 +190,17 @@ public bool TryRead(out object data) return false; } + public bool TryPeed(out object data) + { + int oldCurIndex = _curIndex; + if (TryRead(out data)) + { + _curIndex = oldCurIndex; + return true; + } + return false; + } + public object Read(bool notSkip = false) { //if (curIndex <= toIndex)