TinyConfig——Excel快速轉換CSV工具,並生成CSharp讀取配置檔案
阿新 • • 發佈:2018-11-27
TinyConfig
Excel快速轉換CSV工具,並生成CSharp讀取配置檔案。
包含功能: 轉客戶端csv,客戶端讀取配置的CSharp程式碼;轉伺服器csv,後續支援直轉資料庫
具體程式碼:https://github.com/garsonlab/TinyConfig
Excel表頭格式
輸出 | OtherDef | ||||||||
---|---|---|---|---|---|---|---|---|---|
伺服器 | Level | Exp | Max | Property | Type | Name | Model | ||
客戶端 | Id | Level | Name | Exp#Min | Exp#Max | Property#1 | Property#2 | Monster#1#1#Name | Monster#1#2#Name |
型別 | _key | _key | text | int | int | int | int | text | text |
說明 | id | 等級 | 名字 | 經驗 | 最大經驗 | 屬性 | 型別 | 名字1 | 名字2 |
欄位說明
- 輸出:生成的csv\cs檔案、類名
- 伺服器:標識伺服器使用欄位,不填不會轉換
- 客戶端:同伺服器
- 型別:支援 text(string), int, byte, long, float, double
- _key指主鍵,用於查詢配置表使用,至少1個,至多3個,型別為int
生成CSharp檔案中,欄位分割使用“#”,遇到數字自動識別成陣列,其他識別成類。陣列下標從1開始
Converter轉換器使用
public struct Options { public string excelPath;//excel public string serverFolder;//server csv public string clientFolder;//client csv public string csFolder;//csharp public string nameSpace;//csharp 名稱空間 }
栗子
使用“測試.xlsx”進行轉換,根據下方的table生成兩個CSharp檔案, CombatExpDef, OtherExpDef
每個類包含3個靜態模組:
- Load(string),載入讀取的csv資料
- Values,所有def的List
- Find(int ...), 根據上方標識的“_key”獲取單個配置項