千家信息网

Excel转Json工具(资源配置基础)

发表于:2024-10-05 作者:千家信息网编辑
千家信息网最后更新 2024年10月05日,一 , 1.0.0.0版工具特点:① , 支持字段类型( int / float / string / bool / int[] / float[] / string[] / bool[] )② ,
千家信息网最后更新 2024年10月05日Excel转Json工具(资源配置基础)

一 , 1.0.0.0版工具特点:

① , 支持字段类型( int / float / string / bool / int[] / float[] / string[] / bool[] )
② , 支持前端/后端差异配置
③ , 支持说明书sheet
④ , 支持更改编码方式
⑤ , 支持展开/收缩属性结构
⑥ , 支持Array模式
⑦ , 支持多sheet配置方式
⑧ , 其他基础的功能

二 , 使用方式

    ① , 此工具是使用DOS命令的方式来运行的 , 帮助如下图:


现对各个命令做解释:
1` -e 或者 --excel (以下只写短命令) : excel的相对位置

2` -j : 导出的json的名称3` -h : sheet的头的行数(我建议用5个)4` -c : 编码方式5` -l : 字段名称是否转为小写6` -a : 是否使用Array模式7` -q : 是否为前端配置8` -i : 最后一个sheet是否为说明书(如果是则不导出config)9` -o : 导出的json是否是树形结构展开

② , 关于资源的位置
如果相对于AonauflyConfig.exe同级目录的话 , 直接使用 --excel xxx.xlsx 和 --json xxx.json;
如果不是 , 这样相对应地使用../等 , 获取相对目录
③ , 给出几个命令(需要在AonauflyConfig.exe同级目录打开cmd窗口)
1 : AonauflyConfig --excel test.xlsx --json test.json --header 5 --qianduan true --instruction true --open true
意思 : 将test.xlsx 导到 同级目录 test.json ; sheet的标题行数为5 ; 前端配置 ; 树形结构展开


2 : AonauflyConfig --excel test.xlsx --json test.json --header 5 --array false --qianduan true --instruction true
意思:将test.xlsx 到到 同级目录 test.json ; sheet的标题行数为5 ; Array模式;前端配置 ; 最后的sheet为说明表(不打印)

三 , 看excel的配置


1` 第一行(固定) : 字段名称

2` 第二行(固定) : 字段类型

3` 第三行(固定) : 后端 (Y : 打印 / N : 不打印)

4` 第四行(固定) : 前端( Y : 打印 / N : 不打印 )

5` ~ n 随意填写

四 , 查看打印的前端数据如下 :

{"Model":{  "1": {    "id": 1,    "description": "力量型",    "agility": 10,    "brains": 10,    "initHp": 200,    "initMagic": 100,    "powerIncrease": 5.0,    "agilityIncrease": 2.5,    "brainsIncrease": 2.5,    "speed": 300,    "skillIdList": [      1,      2,      3,      4,      5,      6,      7,      8,      9    ]  },  "2": {    "id": 2,    "description": "敏捷型",    "agility": 25,    "brains": 10,    "initHp": 125,    "initMagic": 175,    "powerIncrease": 2.5,    "agilityIncrease": 5.0,    "brainsIncrease": 2.5,    "speed": 400,    "skillIdList": [      1,      2,      3,      4,      5,      6,      7,      8,      10    ]  },  "3": {    "id": 3,    "description": "智力型",    "agility": 10,    "brains": 25,    "initHp": 100,    "initMagic": 200,    "powerIncrease": 2.5,    "agilityIncrease": 2.5,    "brainsIncrease": 5.0,    "speed": 300,    "skillIdList": [      1,      2,      3,      4,      5,      6,      7,      8,      11    ]  },  "4": {    "id": 4,    "description": "力敏型",    "agility": 18,    "brains": 9,    "initHp": 175,    "initMagic": 125,    "powerIncrease": 4.0,    "agilityIncrease": 4.0,    "brainsIncrease": 2.0,    "speed": 350,    "skillIdList": [      1,      2,      3,      4,      5,      6,      7,      8,      12    ]  },  "5": {    "id": 5,    "description": "敏智型",    "agility": 18,    "brains": 18,    "initHp": 125,    "initMagic": 175,    "powerIncrease": 2.0,    "agilityIncrease": 4.0,    "brainsIncrease": 4.0,    "speed": 350,    "skillIdList": [      1,      2,      3,      4,      5,      6,      7,      8,      13    ]  },  "6": {    "id": 6,    "description": "力智型",    "agility": 9,    "brains": 18,    "initHp": 175,    "initMagic": 125,    "powerIncrease": 4.0,    "agilityIncrease": 2.0,    "brainsIncrease": 4.0,    "speed": 300,    "skillIdList": [      1,      2,      3,      4,      5,      6,      7,      8,      14    ]  },  "7": {    "id": 7,    "description": "综合型",    "agility": 15,    "brains": 15,    "initHp": 150,    "initMagic": 150,    "powerIncrease": 3.33,    "agilityIncrease": 3.33,    "brainsIncrease": 3.33,    "speed": 325,    "skillIdList": [      1,      2,      3,      4,      5,      6,      7,      8,      15    ]  }}}

可以看出sheet名称作为了config每个表的title. 并且power字段和xxx字段是没有的..

五 , 参考

https://github.com/neil3d/excel2json
本人在此代码上进行了扩展及修改 ... 感谢万能的互联网.

0