From 258f657ce83a370eedf85bdc23b55a5f86adb269 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 27 Oct 2021 17:38:28 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=BD=93A1=E5=8D=95=E5=85=83=E6=A0=BC=E4=B8=BAnull?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=88=A4=E5=AE=9AStartWith("##")=E6=8A=9B?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/data_excel.md | 165 +++++++----------- .../Source/DataSources/Excel/SheetLoadUtil.cs | 2 +- 2 files changed, 62 insertions(+), 105 deletions(-) diff --git a/docs/data_excel.md b/docs/data_excel.md index d6bb91b..750e71b 100644 --- a/docs/data_excel.md +++ b/docs/data_excel.md @@ -3,32 +3,23 @@ ## bool 类型 -- 新增 一个字段 batch_useable,表示能否批量使用 -- 用 true 或 false 表示 bool 值,只需要小写后是这两个值即可,比如 true,True,True 都是合法的值。excel 会自动将输入的值大写化。 -- [定义](images/adv/def_02.png): - ```xml - - - - - - ``` -- 配置: - ![如图](images/adv/def_01.png) +用 true 或 false 表示 bool 值,只需要小写后是这两个值即可,比如 true,True,True 都是合法的值。excel 会自动将输入的值大写化。 + + + +|##| id | x| +|-|-|-| +|##type|int| bool| +|| 1| true| +||2| false | ## float 类型 -- 新增一个 float 类型字段,掉落概率 drop_prob. -- [定义](images/adv/def_04.png): - ```xml - - - - - - ``` -- 配置: - ![如图](images/adv/def_03.png) +|##| id | x| +|-|-|-| +|##type|int| float| +|| 1| 1.2| +||2| 4.895 | ## byte,short,int,long,string @@ -41,28 +32,14 @@ 可能会有疑问,如何恰好想表达 ""是怎么办呢? 如果真遇到这种需求,再寻找解决方案吧。 -定义: +|##| id | x| +|-|-|-| +|##type|int| string| +|| 1| aaabbb| +||2| | +||3| ""| -```xml - - - - - - - - - - - - - - -``` -配置数据: - -![配置](images/examples/ex_string_01.png) ## text 类型 @@ -73,21 +50,13 @@ text的key和text字段都是string类型,因此在连续单元格或者sep产生的连续数据流模式中,同样要遵循用""来表达空白字符串的规则。 -定义: - -```xml - - - - - -
-``` - -配置数据: - -![数据](images/examples/ex_i10n_2.png) +|##| id | x&sep=| +|-|-|-| +|##type|int| text| +|| 1| /demo/key1#aaaa| +||2| /demo/key2#bbbb| +||3| | | ## datetime 类型 @@ -101,62 +70,43 @@ text的key和text字段都是string类型,因此在连续单元格或者sep产 - yyyy-mm-dd 如 2003-04-05 - 以 excel内置的时间格式填写 -- 为 Item 新增一个 失效时间字段 expire_time 。 -- [定义](images/adv/def_38.png) - ``` xml - - ... - - - ``` -- 配置 - 图中红框中第一个时间以 excel的时间格式填写 - 剩下第2,3,4个时间以 纯字符串形式填写 - ![如图](images/adv/def_39.png) +|##| id | x| +|-|-|-| +|##type|int| datetime| +|| 1|1999-09-09 01:02:03| +||2| 1999-09-09 01:02| +||3| 1999-09-09 01 | +||4| 1999-09-09| ## 可空变量 - 有时候会有一种变量,我们希望它 功能生效时填一个有效值,功能不生效里,用一个值来表示。 例如 int 类型,常常拿 0 或者-1 作无效值常量。 但有时候,0 或-1 也是有效值时,这种做法就不生效了。或者说 项目组内 有时候拿 0,有时候拿-1 作无效值标记,很不统一。我们借鉴 sql 及 c#,引入 可空值概念,用 null 表达空值。 -- 我们为 Item 添加 min_use_level 字段,类型为 int? 当填有效值时,使用时要检查等级,否则不检查。 -- [定义](images/adv/def_36.png) - ``` xml - - ... - - - ``` -- 配置 - ![如图](images/adv/def_37.png) + +|##| id | x| color | +|-|-|-| - | +|##type|int| int?|QualityColor?| +|| 1| 1| A | +||2| null|B| +||3| 2|null| ## 列表类型 list,int -- 我们新增一个字段, 宝箱的随机抽取道具列表 random_item_ids。 -- [定义](images/adv/def_06.png) - ```xml - - - - - - ``` -- 配置: - ![如图](images/adv/def_05.png) +|##| id | x| +|-|-|-| +|##type|int| list,int| +|| 1| 12,33,44| +||2| 10,20,30,40| -## 向量类型 vector3 +## 向量类型 vector2,vector3,vector4 -- vector3 有三个字段 float x, float y, float z, 适合用于表示坐标之类的数据。 -- 我们新增一个 spawn_location 字段,表示物品产生的场景位置。 -- [定义](images/adv/def_08.png): - ```xml - - - - - - ``` -- 配置: - ![如图](images/adv/def_07.png) +vector3 有三个字段 float x, float y, float z, 适合用于表示坐标之类的数据。 + +|##| id | x2|x3|x4| +|-|-|-| -| -| +|##type|int| vector2|vector3|vector4| +|| 1| 1,2|11,22,33|12,33,44,55| +||2| 2,3|22,44,55|6.5,4.7,8.9| ## 枚举类型 @@ -199,7 +149,14 @@ text的key和text字段都是string类型,因此在连续单元格或者sep产 - excel 表中,想表达一个枚举值,既可以用检举项 name,也可以用枚举项的 alias,但不能是相应的整数值。 - 注意!如果想引用其他模块定义的 enum 或者 bean, type 里必须指定全名。 比如 type=”mall.TradeInfo” 。 -- ![如图](images/adv/def_11.png) + +|##| id | color | +|-|-| - | +|##type|int| QualityColor?| +|| 1| GREEN | +||2| RED| +||3| 白| + ## bean 类型 diff --git a/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs b/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs index 3e30b75..0942a87 100644 --- a/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs +++ b/src/Luban.Job.Cfg/Source/DataSources/Excel/SheetLoadUtil.cs @@ -221,7 +221,7 @@ namespace Luban.Job.Cfg.DataSources.Excel tableName = ""; // meta 行 必须以 ##为第一个单元格内容,紧接着 key:value 形式 表达meta属性 - if (!metaStr.StartsWith("##")) + if (string.IsNullOrEmpty(metaStr) || !metaStr.StartsWith("##")) { return false; }