From 54e195511278f35a47bd07fec75e9cc7fafaff03 Mon Sep 17 00:00:00 2001 From: walon Date: Sat, 29 Jan 2022 14:54:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=8A=E6=AC=A1=E8=B0=83=E6=95=B4sep=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E5=BC=95=E8=B5=B7=E7=9A=84=E8=AF=BB=E5=8F=96=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E6=95=B0=E6=8D=AE=E5=88=97=E8=A1=A8=E5=8F=AA=E8=AF=BB?= =?UTF-8?q?=E5=88=B0=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataCreators/ExcelStreamDataCreator.cs | 3 ++- .../Source/DataSources/Excel/ExcelStream.cs | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs index 26acfa1..543e819 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs @@ -422,7 +422,8 @@ namespace Luban.Job.Cfg.DataCreators string sep = type.GetTag("sep"); if (string.IsNullOrEmpty(sep) && type.ElementType != null && type.ElementType.Apply(IsNotSepTypeVisitor.Ins)) { - sep = DataUtil.SimpleContainerSep; + // 如果是array,list,set,并且它们的elementType不包含',;|',则自动添加sep分割。这是一个方便策划的优化 + return stream.CreateAutoSepStream(DataUtil.SimpleContainerSep); } if (!string.IsNullOrEmpty(sep) && !stream.TryReadEOF()) diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs index c29b8fd..5422ec7 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelStream.cs @@ -265,10 +265,10 @@ namespace Luban.Job.Cfg.DataSources.Excel int oldIndex = _curIndex; while (_curIndex <= _toIndex) { - var value = _datas[_curIndex++].Value?.ToString(); + var value = _datas[_curIndex++].Value; if (!IsSkip(value)) { - if (value == END_OF_LIST) + if (value is string s && s == END_OF_LIST) { LastReadIndex = _curIndex - 1; return true; @@ -284,5 +284,23 @@ namespace Luban.Job.Cfg.DataSources.Excel _curIndex = oldIndex; return true; } + + internal ExcelStream CreateAutoSepStream(string simpleContainerSep) + { + int startIndex = _curIndex; + while (_curIndex <= _toIndex) + { + var value = _datas[_curIndex++].Value; + if (!IsSkip(value)) + { + if (value is string s && s == END_OF_LIST) + { + break; + } + } + } + LastReadIndex = _curIndex - 1; + return new ExcelStream(_datas, startIndex, LastReadIndex, simpleContainerSep, ""); + } } }