From 6e994e7729f0609a8c87d664351f69b43493980d Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 29 Oct 2021 14:24:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96excel=E4=B8=AD=E5=A4=9A=E7=BA=A7=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E5=A4=B4=E6=97=B6#desc=E7=9A=84=E8=A7=A3=E6=9E=90=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/DataSources/Excel/SheetLoadUtil.cs | 29 ++++++++++++++++++- src/Luban.Job.Common/Source/Utils/DefUtil.cs | 3 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs index 4f9b3da..6894011 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs @@ -437,12 +437,39 @@ namespace Luban.Job.Cfg.DataSources.Excel { continue; } + string desc = ""; + if (descRow != null) + { + // 如果有子字段,并且子字段个数>=2时,如果对应注释行有效注释个数为1,表示这是给当前字段的注释, + // 否则是给子字段的注释,取注释为空,而不是第一个注释 + if (subTitle.SubTitles.Count >= 2) + { + int notEmptyCellCount = 0; + for (int i = subTitle.FromIndex; i <= subTitle.ToIndex; i++) + { + var cellValue = descRow?[i].Value?.ToString(); + if (!string.IsNullOrWhiteSpace(cellValue)) + { + ++notEmptyCellCount; + desc = cellValue; + } + } + if (notEmptyCellCount > 1) + { + desc = ""; + } + } + else + { + desc = descRow?[subTitle.FromIndex].Value?.ToString() ?? ""; + } + } fields.Add(subTitle.Name, new FieldInfo() { Name = subTitle.Name, Tags = title.Tags, Type = typeRow[subTitle.FromIndex].Value?.ToString() ?? "", - Desc = descRow?[subTitle.FromIndex].Value?.ToString() ?? "", + Desc = desc, }); } diff --git a/src/Luban.Job.Common/Source/Utils/DefUtil.cs b/src/Luban.Job.Common/Source/Utils/DefUtil.cs index 78068f7..10c4ab4 100644 --- a/src/Luban.Job.Common/Source/Utils/DefUtil.cs +++ b/src/Luban.Job.Common/Source/Utils/DefUtil.cs @@ -159,7 +159,6 @@ namespace Luban.Job.Common.Utils public static string EscapeCommentByCurrentLanguage(string comment) { - //comment = comment.Replace('\n', ' ').Replace('\r', ' '); var curLan = DefAssemblyBase.LocalAssebmly.CurrentLanguage; switch (curLan) { @@ -172,7 +171,7 @@ namespace Luban.Job.Common.Utils case ELanguage.JS: case ELanguage.TYPESCRIPT: case ELanguage.PYTHON: - case ELanguage.RUST: return WebUtility.HtmlDecode(comment).Replace("\n", "
"); + case ELanguage.RUST: return System.Web.HttpUtility.HtmlEncode(comment).Replace("\n", "
"); default: throw new Exception($"unknown language:{curLan}"); } }