From 5482b0a5dec7e9fcc19910e8634dacd8ff735501 Mon Sep 17 00:00:00 2001 From: walon Date: Tue, 17 Aug 2021 13:35:10 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B0=83=E6=95=B4=E3=80=91=E8=B0=83?= =?UTF-8?q?=E6=95=B4excel=E5=A4=9A=E8=A1=8C=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E6=96=B9=E5=BC=8F=E3=80=82=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E5=AF=B9=E9=A1=B6=E7=BA=A7=E5=A4=9A=E8=A1=8C=E6=89=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=8E=E8=AF=A5=E8=AE=B0=E5=BD=95=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E8=A1=8C=E9=9D=9E=E5=A4=9A=E8=A1=8C=E5=AD=97=E6=AE=B5=E7=9B=B8?= =?UTF-8?q?=E5=BA=94=E5=8D=95=E5=85=83=E6=A0=BC=E5=80=BC=E5=AE=8C=E5=85=A8?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E6=97=B6=EF=BC=8C=E5=88=A4=E5=AE=9A=E8=AF=A5?= =?UTF-8?q?=E8=A1=8C=E5=B1=9E=E4=BA=8E=E5=BD=93=E5=89=8D=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 ++++++------ .../Source/DataSources/Excel/Sheet.cs | 20 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f7072e2..7c4ad55 100644 --- a/README.md +++ b/README.md @@ -80,13 +80,14 @@ Luban适合有以下需求的开发者: - python (3.0+) - 支持主流引擎和平台 - unity + c# - - unity + tolua、xlua - - unity + ILRuntime - - unity + puerts + - unity + [tolua](https://github.com/topameng/tolua)、[xlua](https://github.com/Tencent/xLua) + - unity + [ILRuntime](https://github.com/Ourpalm/ILRuntime) + - unity + [puerts](https://github.com/Tencent/puerts) + - unity + [ET游戏框架](https://github.com/egametang/ET) - unreal + c++ - - unreal + unlua - - unreal + sluaunreal - - unreal + puerts + - unreal + [unlua](https://github.com/Tencent/UnLua) + - unreal + [sluaunreal](https://github.com/Tencent/sluaunreal) + - unreal + [puerts](https://github.com/Tencent/puerts) - cocos2d-x + lua - cocos2d-x + js - 微信小程序平台 diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs index 8fe6300..7d826d0 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs @@ -38,6 +38,8 @@ namespace Luban.Job.Cfg.DataSources.Excel public class Title { + public bool Root { get; set; } + public int FromIndex { get; set; } public int ToIndex { get; set; } @@ -134,7 +136,7 @@ namespace Luban.Job.Cfg.DataSources.Excel { var fieldTitle = title.SubTitles[f.Name]; return Sheet.IsBlankRow(row, fieldTitle.FromIndex, fieldTitle.ToIndex); - }) || (recordRows != null && notMultiRowFields.All(f => + }) || (title.Root && recordRows != null && notMultiRowFields.All(f => { var fieldTitle = title.SubTitles[f.Name]; return Sheet.IsSameRow(row, recordRows[0], fieldTitle.FromIndex, fieldTitle.ToIndex); @@ -206,7 +208,11 @@ namespace Luban.Job.Cfg.DataSources.Excel { if (Titles.TryGetValue(name, out var title)) { - // CheckEmptySinceSecondRow(name, title.FromIndex, title.ToIndex); + // 只有顶级root支持才允许非multi_rows字段与第一行相同时,判定为同个记录 + if (!this.SelfTitle.Root) + { + CheckEmptySinceSecondRow(name, title.FromIndex, title.ToIndex); + } var es = new ExcelStream(Rows[0], title.FromIndex, title.ToIndex, sep, namedMode); return es; } @@ -216,13 +222,6 @@ namespace Luban.Job.Cfg.DataSources.Excel } } - //public NamedRow GetSubTitleNamedRow(string name) - //{ - // Title title = this.Titles[name]; - // CheckEmptySinceSecondRow(name, title.FromIndex, title.ToIndex); - // return new NamedRow(title, this.Rows[0]); - //} - public NamedRow GetSubTitleNamedRow(string name) { Title title = Titles[name]; @@ -435,6 +434,7 @@ namespace Luban.Job.Cfg.DataSources.Excel } } + const string ROOT_TITLE_NAME = "____"; private void LoadRemainRows(IExcelDataReader reader, bool headerOnly) { @@ -486,7 +486,7 @@ namespace Luban.Job.Cfg.DataSources.Excel throw new Exception($"没有定义字段名行"); } - _rootTitle = new Title() { Name = "_root_", FromIndex = 1, ToIndex = rows.Select(r => r.Count).Max() - 1 }; + _rootTitle = new Title() { Root = true, Name = ROOT_TITLE_NAME, FromIndex = 1, ToIndex = rows.Select(r => r.Count).Max() - 1 }; int titleRowNum = 1; if (reader.MergeCells != null)