diff --git a/.gitignore b/.gitignore index 6d49f9c..9bf182d 100644 --- a/.gitignore +++ b/.gitignore @@ -265,3 +265,5 @@ __pycache__/ # gen cache meta file .cache.meta +/config/output_code +/config/output_data diff --git a/config/Datas/test/full_type.xlsx b/config/Datas/test/full_type.xlsx index eba555b..ba9641a 100644 Binary files a/config/Datas/test/full_type.xlsx and b/config/Datas/test/full_type.xlsx differ diff --git a/config/Datas/test/multi_level_title.xlsx b/config/Datas/test/multi_level_title.xlsx index 612735c..664602a 100644 Binary files a/config/Datas/test/multi_level_title.xlsx and b/config/Datas/test/multi_level_title.xlsx differ diff --git a/config/Datas/test/multi_rows_record.xlsx b/config/Datas/test/multi_rows_record.xlsx index bc0fa38..6c3701f 100644 Binary files a/config/Datas/test/multi_rows_record.xlsx and b/config/Datas/test/multi_rows_record.xlsx differ diff --git a/config/Datas/test/table_one.xlsx b/config/Datas/test/table_one.xlsx index 2fa9c5a..2205225 100644 Binary files a/config/Datas/test/table_one.xlsx and b/config/Datas/test/table_one.xlsx differ diff --git a/config/Datas/test/tb_role_csv.csv b/config/Datas/test/tb_role_csv.csv index 00465d9..def2350 100644 --- a/config/Datas/test/tb_role_csv.csv +++ b/config/Datas/test/tb_role_csv.csv @@ -1,12 +1,9 @@ -##,align:true,row:true,,,,,,,,,,,,,,,,,,,,,, -__type__,x1,x2,x3,x4,x5,x6,x7,x8,x8_0,x9,x10,x11,x12,x13,,,k1,k2,k3,k4,k5,k6,k7,k8 -,ֹ,x2:byte,x3:short,x4:int,x5:long, x6:float,x7:double,,,,,,,,,,array:int,array:int,array:int,array:int,array:int,array:int,array:int,map:int:int - DemoD2,TRUE,5,5,10000,13234234234,1.28,1.23457891,1234,1234,111111111,huang,,1988,A,,,"1,2,3","1,2,4","1,2,5","1,2,6","1,2,7","1,2,8","1,2,9","1,2,3,4" -,FALSE,0,6,198704,34523452345,2.5,19870421.2,453234,-345,112233445566 ,qiang,,1987,B,,,"2,4,6","2,4,7","2,4,8","2,4,9","2,4,10","2,4,11","2,4,12","1,10,2,20" -,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,, -,,,,,,,,,,,,,,,,,,,,,,,, +##,,,,,,,,,,,,,,,,,,,,,,,, +,,,,,,,,,,,,,,,,,,,,,,,, +__type__,x1,x2,x3,x4,x5,x6,x7,x8,x8_0,x9,x10,x11,x12,x13,,,k1,k2,k3,k4,k5,k6,k7,k8 +,,,,,,,,,,,,,,,,,,,,,,,, +,ֹ,x2:byte,x3:short,x4:int,x5:long, x6:float,x7:double,,,,,,,,,,array:int,array:int,array:int,array:int,array:int,array:int,array:int,map:int:int +,,,,,,,,,,,,,,,,,,,,,,,, + DemoD2,TRUE,5,5,10000,13234234234,1.28,1.23457891,1234,1234,111111111,huang,,1988,A,,,"1,2,3","1,2,4","1,2,5","1,2,6","1,2,7","1,2,8","1,2,9","1,2,3,4" +,,,,,,,,,,,,,,,,,,,,,,,, +,FALSE,0,6,198704,34523452345,2.5,19870421.2,453234,-345,1.12233E+11,qiang,,1987,B,,,"2,4,6","2,4,7","2,4,8","2,4,9","2,4,10","2,4,11","2,4,12","1,10,2,20" diff --git a/config/生成code_cs_bin和data_bin.bat b/config/生成code_cs_bin和data_bin.bat index fc11c44..3e21584 100644 --- a/config/生成code_cs_bin和data_bin.bat +++ b/config/生成code_cs_bin和data_bin.bat @@ -1,4 +1,4 @@ -..\src\Luban.Client\bin\Debug\netcoreapp3.1\Luban.Client.exe ^ +..\src\Luban.Client\bin\Debug\net5.0\Luban.Client.exe ^ -h 127.0.0.1 ^ -j cfg ^ -- ^ diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs index f420768..37303b2 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/ExcelDataSource.cs @@ -1,9 +1,11 @@ using ExcelDataReader; using Luban.Job.Cfg.Datas; +using Luban.Job.Cfg.Defs; using Luban.Job.Common.Types; using System; using System.Collections.Generic; using System.IO; +using System.Linq; namespace Luban.Job.Cfg.DataSources.Excel { @@ -61,7 +63,7 @@ namespace Luban.Job.Cfg.DataSources.Excel { try { - datas.AddRange(sheet.ReadMulti(type)); + datas.AddRange(sheet.ReadMulti(type, ((DefBean)type.Bean).IsMultiRow)); } catch (Exception e) { diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs index 90b3369..2d374a2 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs @@ -14,10 +14,6 @@ namespace Luban.Job.Cfg.DataSources.Excel private bool OrientRow { get; set; } = true; // 以行为数据读取方向 - private bool Align { get; set; } = true;// 标题头与数据严格对齐的 固定列格式 - - private bool IsMultiRow { get; set; } - private int TitleRows { get; set; } = 3; // 默认有三行是标题行. 第一行是字段名,第二行是中文描述,第三行是注释 public string Name { get; } @@ -209,12 +205,6 @@ namespace Luban.Job.Cfg.DataSources.Excel return false; } - s_logger.Trace("align:{align} row:{orient}", Align, OrientRow); - if (!Align) - { - throw new Exception($"当前不支持 align:false"); - } - LoadRemainRows(reader); return true; @@ -249,31 +239,20 @@ namespace Luban.Job.Cfg.DataSources.Excel string value = ss[1]; switch (key) { - case "align": - { - if (!bool.TryParse(value, out var v)) - { - throw new Exception($"单元薄 meta 定义 align:{value} 属性值只能为true或false"); - } - Align = v; - break; - } case "row": { - if (!bool.TryParse(value, out var v)) + if (int.TryParse(value, out var v1)) { - throw new Exception($"单元薄 meta 定义 row:{value} 属性值只能为true或false"); + OrientRow = v1 != 0; } - OrientRow = v; - break; - } - case "multi_rows": - { - if (!bool.TryParse(value, out var v)) + else if (bool.TryParse(value, out var v2)) { - throw new Exception($"单元薄 meta 定义 multi_rows:{value} 属性值只能为true或false"); + OrientRow = v2; + } + else + { + throw new Exception($"单元薄 meta 定义 row:{value} 属性值只能为true或false或0或1"); } - IsMultiRow = v; break; } case "title_rows": @@ -289,19 +268,6 @@ namespace Luban.Job.Cfg.DataSources.Excel TitleRows = v; break; } - case "ignore": - { - if (!bool.TryParse(value, out var v)) - { - throw new Exception($"单元薄 meta 定义 ignore:{value} 属性值只能为true或false"); - } - if (v) - { - return false; - } - - break; - } default: { throw new Exception($"非法单元薄 meta 属性定义 {attr}"); @@ -623,11 +589,11 @@ namespace Luban.Job.Cfg.DataSources.Excel - public List ReadMulti(TBean type) + public List ReadMulti(TBean type, bool enableMultiRowRecord) { var datas = new List(); - for (DType data; (data = ReadOne(type)) != null;) + for (DType data; (data = ReadOne(type, enableMultiRowRecord)) != null;) { datas.Add(data); } @@ -635,9 +601,9 @@ namespace Luban.Job.Cfg.DataSources.Excel } private int curReadIndex = 0; - public DType ReadOne(TBean type) + public DType ReadOne(TBean type, bool enableMultiRowRecord) { - if (!IsMultiRow) + if (!enableMultiRowRecord) { List row = GetNextRecordRow(); if (row == null)