[new] 新增表格对##group的支持

[new] 新增表格对##group的支持


Co-authored-by: Tianbao Lin <kteong1012@outlook.com>
main
Carson - 宝鱼 2022-10-13 17:48:42 +08:00 committed by GitHub
parent 14faa26565
commit 30a4ce12db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using System; using DocumentFormat.OpenXml.EMMA;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -15,6 +16,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
public string Type { get; set; } public string Type { get; set; }
public string Desc { get; set; } public string Desc { get; set; }
public string Groups { get; set; }
} }
class RawSheetTableDefInfo class RawSheetTableDefInfo

View File

@ -87,6 +87,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
"desc", "desc",
"comment", "comment",
"column", "column",
"group",
}; };
private const char s_sep = '#'; private const char s_sep = '#';
@ -450,6 +451,10 @@ namespace Luban.Job.Cfg.DataSources.Excel
{ {
return IsRowTagEqual(row, "##type"); return IsRowTagEqual(row, "##type");
} }
private static bool IsGroupRow(List<Cell> row)
{
return IsRowTagEqual(row, "##group");
}
private static bool IsHeaderRow(List<Cell> row) private static bool IsHeaderRow(List<Cell> row)
{ {
@ -577,7 +582,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
{ {
descRow = cells.Count > 1 ? cells.Skip(1).FirstOrDefault(row => IsRowTagEqual(row, "##")) : null; descRow = cells.Count > 1 ? cells.Skip(1).FirstOrDefault(row => IsRowTagEqual(row, "##")) : null;
} }
List<Cell> groupRow = cells.Find(row => IsGroupRow(row));
var fields = new Dictionary<string, FieldInfo>(); var fields = new Dictionary<string, FieldInfo>();
foreach (var subTitle in title.SubTitleList) foreach (var subTitle in title.SubTitleList)
{ {
@ -617,6 +622,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
Name = subTitle.Name, Name = subTitle.Name,
Tags = subTitle.Tags, Tags = subTitle.Tags,
Type = typeRow[subTitle.FromIndex].Value?.ToString() ?? "", Type = typeRow[subTitle.FromIndex].Value?.ToString() ?? "",
Groups = groupRow?[subTitle.FromIndex].Value?.ToString() ?? "",
Desc = desc, Desc = desc,
}); });
} }

View File

@ -367,9 +367,7 @@ namespace Luban.Job.Cfg.Defs
} }
cf.Comment = f.Desc; cf.Comment = f.Desc;
cf.Type = attrs[0]; cf.Type = attrs[0];
for (int i = 1; i < attrs.Length; i++) for (int i = 1; i < attrs.Length; i++)
{ {
var pair = attrs[i].Split('=', 2); var pair = attrs[i].Split('=', 2);
@ -411,6 +409,11 @@ namespace Luban.Job.Cfg.Defs
} }
} }
if (!string.IsNullOrEmpty(f.Groups))
{
cf.Groups = f.Groups.Split(',').Select(s => s.Trim()).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
}
cb.Fields.Add(cf); cb.Fields.Add(cf);
} }
return cb; return cb;