public List <object> ReadList(ISheet sheet) { Schema schema = EDSchemaReader.ReadSchema(sheet); EDDataReader reader = new EDDataReader(); return(EDDataReader.ReadList(sheet, schema)); }
void DoLoad() { var xlsFile = EditorUtility.OpenFilePanel("load excel file", "", "xls;*.xlsx;"); if (xlsFile.Length != 0) { m_Workbook = ExcelHelper.Load(xlsFile); //第一张表 ISheet sheet = m_Workbook.GetSheetAt(0); m_Schema = EDSchemaReader.ReadSchema(sheet); //第一列为Key,其它为语言 List <LangItem> list = new List <LangItem>(); for (int i = 1; i < m_Schema.fields.Count; ++i) { LangItem item = new LangItem(); item.name = m_Schema.fields[i].name; item.convertable = true; list.Add(item); } m_LangItems = list.ToArray(); } }
public static void TestData3() { string fileName = Application.dataPath + "/Tests/Editor/Gacha3.xlsx"; IWorkbook workbook = ExcelHelper.Load(fileName); ISheet sheet = workbook.GetSheetAt(0); Schema schema = EDSchemaReader.ReadSchema(sheet); EDDataReader reader = new EDDataReader(); List <object> dataList = EDDataReader.ReadList(sheet, schema); Debug.Log(dataList.Count); foreach (Dictionary <string, object> iter in dataList) { Debug.LogFormat("{0},{1},{2}", iter["name"], iter["probability"], iter["items"]); List <float> items = iter["items"] as List <float>; string o = ""; foreach (float 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 ConvertSheet(ISheet sheet, string savePath, string schemaName) { Schema schema = EDSchemaReader.ReadSchema(sheet); schema.name = schemaName; CodeGen gen = new CodeGen(); gen.ns = m_GenNamespace; gen.GenClass(schema, savePath); }
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)); }
//获取数组数据 static object GetArrayData(ISheet sheet, int rowIndex, int colIndex, Type t) { if (t == typeof(int) || t == typeof(int?)) { return(GetListInt(sheet, rowIndex, colIndex).ToArray()); } else if (t == typeof(long) || t == typeof(long?)) { return(GetListLong(sheet, rowIndex, colIndex).ToArray()); } else if (t == typeof(float) || t == typeof(float?)) { return(GetListFloat(sheet, rowIndex, colIndex).ToArray()); } else if (t == typeof(double) || t == typeof(double?)) { return(GetListDouble(sheet, rowIndex, colIndex).ToArray()); } else if (t == typeof(string)) { return(GetListString(sheet, rowIndex, colIndex).ToArray()); } else if (t == typeof(bool) || t == typeof(bool?)) { return(GetListBool(sheet, rowIndex, colIndex).ToArray()); } else if (t == typeof(object)) { Schema schema = EDSchemaReader.ReadSchema(sheet); return(EDDataReader.ReadList(sheet, schema).ToArray()); } else { return(null); } }