【调整】cfg excel meta属性row改名为orientation,同时取值范围由true|false改为landscape|l|row|r|portrait|p|column|c

main
walon 2021-07-31 09:30:52 +08:00
parent 2ca0cebe99
commit a8a341a80f
1 changed files with 18 additions and 15 deletions

View File

@ -250,28 +250,31 @@ namespace Luban.Job.Cfg.DataSources.Excel
continue; continue;
} }
var ss = attr.Split(':'); var ss = attr.Split(':', '=');
if (ss.Length != 2) if (ss.Length != 2)
{ {
throw new Exception($"单元薄 meta 定义出错. attribute:{attr}"); throw new Exception($"单元薄 meta 定义出错. attribute:{attr}");
} }
string key = ss[0].ToLower(); string key = ss[0].ToLower();
string value = ss[1]; string value = ss[1].ToLower();
switch (key) switch (key)
{ {
case "orientation":
{
switch (value)
{
case "r":
case "row": case "row":
case "l":
case "landscape": OrientRow = true; break;
case "c":
case "column":
case "p":
case "portrait": OrientRow = false; break;
default:
{ {
if (int.TryParse(value, out var v1)) throw new Exception($"单元薄 meta 定义 row:{value} 属性值只能为landscape(l,row,r)或portrait(p,row,r)");
{
OrientRow = v1 != 0;
} }
else if (bool.TryParse(value, out var v2))
{
OrientRow = v2;
}
else
{
throw new Exception($"单元薄 meta 定义 row:{value} 属性值只能为true或false或0或1");
} }
break; break;
} }
@ -281,7 +284,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
{ {
throw new Exception($"单元薄 meta 定义 title_rows:{value} 属性值只能为整数[1,10]"); 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"); throw new Exception($"单元薄 title_rows 应该在 [1,10] 范围内,默认是3");
} }
@ -290,7 +293,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
} }
default: default:
{ {
throw new Exception($"非法单元薄 meta 属性定义 {attr}"); throw new Exception($"非法单元薄 meta 属性定义 {attr}, 合法属性有: orientation=landscape|l|r|row|portrait|p|r|row,title_rows=<number>");
} }
} }
} }