Excel轉Json工具(資源配置基礎)

一 , 1.0.0.0版工具特色:

① , 支持字段類型( int / float / string / bool / int[] / float[] / string[] / bool[] )
② , 支持前端/後端差別配置
③ , 支持說明書sheet
④ , 支持更改編碼方式
⑤ , 支持展開/收縮屬性結構
⑥ , 支持Array模式
⑦ , 支持多sheet配置方式
⑧ , 其餘基礎的功能前端

二 , 使用方式

① , 此工具是使用DOS命令的方式來運行的 , 幫助以下圖:

Excel轉Json工具(資源配置基礎)
現對各個命令作解釋:
1` -e 或者 --excel (如下只寫短命令) : excel的相對位置git

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 ; 前端配置 ; 樹形結構展開github


2 : AonauflyConfig --excel test.xlsx --json test.json --header 5 --array false --qianduan true --instruction true
意思:將test.xlsx 到到 同級目錄 test.json ; sheet的標題行數爲5 ; Array模式;前端配置 ; 最後的sheet爲說明表(不打印)json

三 , 看excel的配置

Excel轉Json工具(資源配置基礎)
1` 第一行(固定) : 字段名稱後端

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

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

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

5` ~ n 隨意填寫3d

四 , 查看打印的前端數據以下 :

{"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字段是沒有的..excel

五 , 參考

https://github.com/neil3d/excel2json本人在此代碼上進行了擴展及修改 ... 感謝萬能的互聯網.

相關文章
相關標籤/搜索