[change] remove excel attribute: align,multi_rows,ignore. fix excel errors raised by modification.
parent
b2a9d97eb5
commit
325d19e5ec
|
|
@ -265,3 +265,5 @@ __pycache__/
|
||||||
# gen cache meta file
|
# gen cache meta file
|
||||||
.cache.meta
|
.cache.meta
|
||||||
|
|
||||||
|
/config/output_code
|
||||||
|
/config/output_data
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -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
|
__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
|
,˝űÖš,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"
|
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"
|
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,
|
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,
|
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,
|
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,
|
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,
|
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,
|
|
||||||
,,,,,,,,,,,,,,,,,,,,,,,,
|
,,,,,,,,,,,,,,,,,,,,,,,,
|
||||||
|
,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"
|
||||||
|
|
|
||||||
|
Can't render this file because it contains an unexpected character in line 4 and column 152.
|
|
|
@ -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 ^
|
-h 127.0.0.1 ^
|
||||||
-j cfg ^
|
-j cfg ^
|
||||||
-- ^
|
-- ^
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using ExcelDataReader;
|
using ExcelDataReader;
|
||||||
using Luban.Job.Cfg.Datas;
|
using Luban.Job.Cfg.Datas;
|
||||||
|
using Luban.Job.Cfg.Defs;
|
||||||
using Luban.Job.Common.Types;
|
using Luban.Job.Common.Types;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Luban.Job.Cfg.DataSources.Excel
|
namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
{
|
{
|
||||||
|
|
@ -61,7 +63,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
datas.AddRange(sheet.ReadMulti(type));
|
datas.AddRange(sheet.ReadMulti(type, ((DefBean)type.Bean).IsMultiRow));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,6 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
|
|
||||||
private bool OrientRow { get; set; } = true; // 以行为数据读取方向
|
private bool OrientRow { get; set; } = true; // 以行为数据读取方向
|
||||||
|
|
||||||
private bool Align { get; set; } = true;// 标题头与数据严格对齐的 固定列格式
|
|
||||||
|
|
||||||
private bool IsMultiRow { get; set; }
|
|
||||||
|
|
||||||
private int TitleRows { get; set; } = 3; // 默认有三行是标题行. 第一行是字段名,第二行是中文描述,第三行是注释
|
private int TitleRows { get; set; } = 3; // 默认有三行是标题行. 第一行是字段名,第二行是中文描述,第三行是注释
|
||||||
|
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
@ -209,12 +205,6 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_logger.Trace("align:{align} row:{orient}", Align, OrientRow);
|
|
||||||
if (!Align)
|
|
||||||
{
|
|
||||||
throw new Exception($"当前不支持 align:false");
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadRemainRows(reader);
|
LoadRemainRows(reader);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -249,31 +239,20 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
string value = ss[1];
|
string value = ss[1];
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case "align":
|
|
||||||
{
|
|
||||||
if (!bool.TryParse(value, out var v))
|
|
||||||
{
|
|
||||||
throw new Exception($"单元薄 meta 定义 align:{value} 属性值只能为true或false");
|
|
||||||
}
|
|
||||||
Align = v;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "row":
|
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;
|
else if (bool.TryParse(value, out var v2))
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "multi_rows":
|
|
||||||
{
|
|
||||||
if (!bool.TryParse(value, out var v))
|
|
||||||
{
|
{
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
case "title_rows":
|
case "title_rows":
|
||||||
|
|
@ -289,19 +268,6 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
TitleRows = v;
|
TitleRows = v;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "ignore":
|
|
||||||
{
|
|
||||||
if (!bool.TryParse(value, out var v))
|
|
||||||
{
|
|
||||||
throw new Exception($"单元薄 meta 定义 ignore:{value} 属性值只能为true或false");
|
|
||||||
}
|
|
||||||
if (v)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
throw new Exception($"非法单元薄 meta 属性定义 {attr}");
|
throw new Exception($"非法单元薄 meta 属性定义 {attr}");
|
||||||
|
|
@ -623,11 +589,11 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<DType> ReadMulti(TBean type)
|
public List<DType> ReadMulti(TBean type, bool enableMultiRowRecord)
|
||||||
{
|
{
|
||||||
var datas = new List<DType>();
|
var datas = new List<DType>();
|
||||||
|
|
||||||
for (DType data; (data = ReadOne(type)) != null;)
|
for (DType data; (data = ReadOne(type, enableMultiRowRecord)) != null;)
|
||||||
{
|
{
|
||||||
datas.Add(data);
|
datas.Add(data);
|
||||||
}
|
}
|
||||||
|
|
@ -635,9 +601,9 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
}
|
}
|
||||||
|
|
||||||
private int curReadIndex = 0;
|
private int curReadIndex = 0;
|
||||||
public DType ReadOne(TBean type)
|
public DType ReadOne(TBean type, bool enableMultiRowRecord)
|
||||||
{
|
{
|
||||||
if (!IsMultiRow)
|
if (!enableMultiRowRecord)
|
||||||
{
|
{
|
||||||
List<Cell> row = GetNextRecordRow();
|
List<Cell> row = GetNextRecordRow();
|
||||||
if (row == null)
|
if (row == null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue