【更新】修正一些过时的excel格式的文档

main
walon 2021-10-28 21:23:21 +08:00
parent eb34a4cb7f
commit 5d8c3d454e
4 changed files with 146 additions and 12 deletions

View File

@ -18,20 +18,26 @@
文件内容如下 文件内容如下
![配置](images/install/install_04.png) |##|id|name|desc|count|
|-|-|-|-|-|
|##type|int|string|string|int|
|##|id|名字|描述|个数|
||1001|item1| desc1| 10|
||1002|item2| desc2| 10|
||1003|item3| desc3| 10|
||1004|item4| desc4| 10|
- 第 1 行是 meta 行包含关于excel文件的元描述title_rows=4表示除了meta行外有4行标题头。此值默认为3可以根据需求调整。
单元格 A1 必须是 ##。表示这是一个有效数据表。 - 第 1 行是 主字段行,包含表字段定义。单元格 A1 必须是 ##。表示这是一个有效数据表。
- 第 2 行是程序字段名行。 - 第 2 行是类型行第1个单元格必须为 ##type。
- 第3行是属性行。格式为 type&属性1=值1&属性2=值2 ... - 第 3 行是注释行。 以##开头。 可以有0-N个注释行而且可以出现在任何位置
- 第 4 行是标题头行。策划自行填写,可留空。 - 第 4 行起是数据行。
- 第 5 行是描述行。策划可以填写字段的补充描述。可留空。
- 从第 6 开始为实际的数据行。如果某个数据行整行为空,则会被跳过。
3. 在 Datas 目录下的__tables__.xlsx添加表声明。如下图 3. 在 Datas 目录下的__tables__.xlsx添加表声明。如下图
![添加声明](images/install/install_10.png) |##|full_name|value_type|define_from_excel|input|index|mode|group|comment|patch_input|tags|output|
|-|-|-|-|-|-|-|-|-|-|-|-|
||demo.TbItem|Item|true|物品表.xlsx||||||||
4. 至此,物品表的创建工作大功告成! 4. 至此,物品表的创建工作大功告成!

View File

@ -410,7 +410,7 @@ namespace Luban.Job.Cfg.DataSources.Excel
if (typeRowIndex < 0) if (typeRowIndex < 0)
{ {
throw new Exception($"缺失type行"); throw new Exception($"缺失type行。请用'##type'标识type行");
} }
List<Cell> typeRow = cells[typeRowIndex]; List<Cell> typeRow = cells[typeRowIndex];
List<Cell> descRow = cells.Count > typeRowIndex + 1 ? cells[typeRowIndex + 1] : null; List<Cell> descRow = cells.Count > typeRowIndex + 1 ? cells[typeRowIndex + 1] : null;

View File

@ -174,12 +174,16 @@ namespace Luban.Job.Common.Defs
return type.Apply(RustTypeNameVisitor.Ins); return type.Apply(RustTypeNameVisitor.Ins);
} }
public static string RustConstValue(TType type, string value) public static string RustConstValue(TType type, string value)
{ {
return type.Apply(LuaConstValueVisitor.Ins, value); return type.Apply(LuaConstValueVisitor.Ins, value);
} }
public static string ErlangDefineType(TType type)
{
return type.Apply(ErlangDefineTypeNameVisitor.Ins);
}
public static bool HasTag(dynamic obj, string attrName) public static bool HasTag(dynamic obj, string attrName)
{ {
return obj.HasTag(attrName); return obj.HasTag(attrName);

View File

@ -0,0 +1,124 @@
using Luban.Job.Common.Types;
namespace Luban.Job.Common.TypeVisitors
{
public class ErlangDefineTypeNameVisitor : ITypeFuncVisitor<string>
{
public static ErlangDefineTypeNameVisitor Ins { get; } = new();
public string Accept(TBool type)
{
return "boolean()";
}
public string Accept(TByte type)
{
return "binary()";
}
public string Accept(TShort type)
{
return "integer()";
}
public string Accept(TFshort type)
{
return "integer()";
}
public string Accept(TInt type)
{
return "integer()";
}
public string Accept(TFint type)
{
return "integer()";
}
public string Accept(TLong type)
{
return "integer()";
}
public string Accept(TFlong type)
{
return "integer()";
}
public string Accept(TFloat type)
{
return "float()";
}
public string Accept(TDouble type)
{
return "float()";
}
public string Accept(TEnum type)
{
return "string()";
}
public string Accept(TString type)
{
return "string()";
}
public string Accept(TBytes type)
{
return "[binary()]";
}
public string Accept(TText type)
{
return "string()";
}
public string Accept(TBean type)
{
return $"'{type.Bean.FullName}'()" ;
}
public virtual string Accept(TArray type)
{
return $"[{type.ElementType.Apply(this)}]";
}
public virtual string Accept(TList type)
{
return $"[{type.ElementType.Apply(this)}]";
}
public virtual string Accept(TSet type)
{
return $"[{type.ElementType.Apply(this)}]";
}
public virtual string Accept(TMap type)
{
return string.Format("#{{0} => {1}}",type.KeyType.Apply(this),type.ValueType.Apply(this));
}
public string Accept(TVector2 type)
{
return "[float()]";
}
public string Accept(TVector3 type)
{
return "[float()]";
}
public string Accept(TVector4 type)
{
return "[float()]";
}
public string Accept(TDateTime type)
{
return "integer()";
}
}
}