From a8a341a80fc36f284572c252f2b5f7e8ca0d5f13 Mon Sep 17 00:00:00 2001 From: walon Date: Sat, 31 Jul 2021 09:30:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B0=83=E6=95=B4=E3=80=91cfg=20excel?= =?UTF-8?q?=20meta=E5=B1=9E=E6=80=A7row=E6=94=B9=E5=90=8D=E4=B8=BAorientat?= =?UTF-8?q?ion,=E5=90=8C=E6=97=B6=E5=8F=96=E5=80=BC=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E7=94=B1true|false=E6=94=B9=E4=B8=BAlandscape|l|row|r|portrait?= =?UTF-8?q?|p|column|c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/DataSources/Excel/Sheet.cs | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs index 7fed36f..fc8d83d 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/Sheet.cs @@ -250,28 +250,31 @@ namespace Luban.Job.Cfg.DataSources.Excel continue; } - var ss = attr.Split(':'); + var ss = attr.Split(':', '='); if (ss.Length != 2) { throw new Exception($"单元薄 meta 定义出错. attribute:{attr}"); } string key = ss[0].ToLower(); - string value = ss[1]; + string value = ss[1].ToLower(); switch (key) { - case "row": + case "orientation": { - if (int.TryParse(value, out var v1)) + switch (value) { - OrientRow = v1 != 0; - } - else if (bool.TryParse(value, out var v2)) - { - OrientRow = v2; - } - else - { - throw new Exception($"单元薄 meta 定义 row:{value} 属性值只能为true或false或0或1"); + case "r": + case "row": + case "l": + case "landscape": OrientRow = true; break; + case "c": + case "column": + case "p": + case "portrait": OrientRow = false; break; + default: + { + throw new Exception($"单元薄 meta 定义 row:{value} 属性值只能为landscape(l,row,r)或portrait(p,row,r)"); + } } break; } @@ -281,7 +284,7 @@ namespace Luban.Job.Cfg.DataSources.Excel { throw new Exception($"单元薄 meta 定义 title_rows:{value} 属性值只能为整数[1,10]"); } - if (v < 1 || v > 10) + if (v < 2 || v > 10) { throw new Exception($"单元薄 title_rows 应该在 [1,10] 范围内,默认是3"); } @@ -290,7 +293,7 @@ namespace Luban.Job.Cfg.DataSources.Excel } default: { - throw new Exception($"非法单元薄 meta 属性定义 {attr}"); + throw new Exception($"非法单元薄 meta 属性定义 {attr}, 合法属性有: orientation=landscape|l|r|row|portrait|p|r|row,title_rows="); } } }