Exemplo n.º 1
0
        public List <object> ReadList(ISheet sheet)
        {
            Schema       schema = EDSchemaReader.ReadSchema(sheet);
            EDDataReader reader = new EDDataReader();

            return(EDDataReader.ReadList(sheet, schema));
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        void ConvertSeprate(string savePath)
        {
            List <object> langData = EDDataReader.ReadList(m_Workbook.GetSheetAt(0), m_Schema);

            string key = string.IsNullOrEmpty(m_KeyField)?  m_Schema.fields[0].name:m_KeyField;

            List <Dictionary <string, object> > multiLangList = new List <Dictionary <string, object> >();
            List <string> enableLangNameList = new List <string>();

            for (int i = 0; i < m_LangItems.Length; ++i)
            {
                if (m_LangItems[i].convertable)
                {
                    multiLangList.Add(new Dictionary <string, object>());
                    enableLangNameList.Add(m_LangItems[i].name);
                }
            }

            //提取数据
            string keyValue;

            foreach (Dictionary <string, object> record in langData)
            {
                for (int i = 0; i < multiLangList.Count; ++i)
                {
                    keyValue = record[key] as string;
                    multiLangList[i][keyValue] = record[enableLangNameList[i]];
                }
            }

            //分别保存
            for (int i = 0; i < multiLangList.Count; ++i)
            {
                string langFile = Path.Combine(savePath, enableLangNameList[i] + ".json");
                SaveToJsonFile(langFile, multiLangList[i]);
            }

            EditorUtility.DisplayDialog("Convert To Lang", "Convert   Lang", "OK");
        }
Exemplo n.º 7
0
 //获取数组数据
 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);
     }
 }