public static void TestReadDict() { string fileName = Application.dataPath + "/Tests/Editor/Gacha.xlsx"; IWorkbook workbook = ExcelHelper.Load(fileName); ISheet sheet = workbook.GetSheetAt(0); Schema schema = EDSchemaReader.ReadSchema(sheet); EDDataReader reader = new EDDataReader(); Dictionary <string, object> dataList = EDDataReader.ReadDictionary(sheet, schema); Debug.Log(dataList.Count); foreach (KeyValuePair <string, object> iter in dataList) { Dictionary <string, object> item = iter.Value as Dictionary <string, object>; Debug.LogFormat("{0},{1},{2}", item["name"], item["probability"], item["items"]); List <string> items = item["items"] as List <string>; string o = ""; foreach (string s in items) { o += s + ","; } Debug.Log(o); } }
void ConvertSheet(ISheet sheet, string savePath, string tableName, string keyName) { Schema schema = EDSchemaReader.ReadSchema(sheet); EDDataReader reader = new EDDataReader(); object dict = EDDataReader.ReadDictionary(sheet, schema, keyName); string filename = Path.Combine(savePath, (string.IsNullOrEmpty(tableName) ? schema.name : tableName) + ".json"); SaveToJsonFile(filename, dict); }
void ConvertAllInOne(string saveFile) { Dictionary <string, object> langData = EDDataReader.ReadDictionary(m_Workbook.GetSheetAt(0), m_Schema, m_KeyField); //remove key in data field string key = string.IsNullOrEmpty(m_KeyField) ? m_Schema.fields[0].name : m_KeyField; foreach (KeyValuePair <string, object> iter in langData) { Dictionary <string, object> record = iter.Value as Dictionary <string, object>; record.Remove(key); } SaveToJsonFile(saveFile, langData); EditorUtility.DisplayDialog("Convert To Lang", "Convert Lang", "OK"); }
public static object GetLinkDict(ICell cell, string keyField, bool removeKeyFieldInElement = false) { if (cell == null || cell.StringCellValue == "") { return(null); } string linkWhere = cell.StringCellValue; CellPosition cp; string linkSheetName = ParseLinkCell(cell, out cp); ISheet linkSheet = cell.Sheet.Workbook.GetSheet(linkSheetName); Schema schema = EDSchemaReader.ReadSchema(linkSheet); //内容要跳过2个头 return(EDDataReader.ReadDictionary(linkSheet, schema, keyField, cp.row + EDConstance.SchemaDataRow, cp.col, null, removeKeyFieldInElement)); }