-
Notifications
You must be signed in to change notification settings - Fork 77
schema_zh
YANG Huan edited this page Sep 17, 2018
·
2 revisions
使用“-c”参数可生成内含Excel格式信息的文件。
例如使用
python proton.py -p "sample.xlsx sample2.xlsx" -f out -e json -c Schema.json -t Conf
导出https://github.com/yanghuan/proton/tree/master/raw/zh 里面的sample.xlsx和sample2.xlsx,会得到Schema.json文件,内容如下
[
{
"item": "Hero",
"exportfile": "out\\HerosConf.xml",
"root": "HerosConf",
"schema": {
"Id": [
"int",
"索引"
],
"Name": [
"string",
"名称"
],
"MountId": [
"int",
"坐骑"
],
"Sex": [
"bool",
"性别"
],
"Height": [
"double",
"身高"
],
"Weapons": [
[
"int"
],
"武器"
],
"Property": [
{
"Hp": [
"int"
],
"Magic": [
"int"
]
},
"主要属性"
],
"Bags": [
[
{
"Id": [
"int"
],
"Count": [
"int"
]
}
],
"背包"
]
}
},
{
"item": "Global",
"exportfile": "out\\GlobalConf.xml",
"root": "GlobalConf",
"schema": {
"NameLimit": [
"int",
"名字字数限制"
],
"HitCorrection": [
"double",
"命中修正系数"
],
"LevelRange": [
{
"Min": [
"int"
],
"Max": [
"int"
]
},
"等级区间"
],
"InitItems": [
[
"int"
],
"初始任务获得道具"
]
}
},
{
"item": "Mount",
"exportfile": "out\\MountsConf.xml",
"root": "MountsConf",
"schema": {
"Id": [
"int",
"索引"
],
"Name": [
"string",
"名称"
]
}
}
]
内容是个数组,数组的每一项描述了一个Sheet页的结构信息,其是一个json对象拥有4个字段,下面具体描述。
-
item 为Sheet页导出标识
-
root 当表头格式为格式1时,为Sheet页导出标识 + ‘s’ + 参数“-t”追加的后缀信息。当表头格式为格式2时,不含中间的字符's'。此字符串也会是生成的配置文件名
-
exportfile 导出的配置文件路径
-
schema 格式信息,json对象,每个字段对应Excel中一个字段的导出信息。字段名同Excel中的字段名,字段值是一个数组,数组第一项,是类型描述,第二项是字段文本描述信息,一般用来生成注释
读取并分析此json文件,便可以完成代码生成工具的开发,具体编码可参考CSharpGeneratorForProton。