public static void ExportTable(ExcelInfo excelInfo) { string path = EditorUtils.DataPath + excelInfo.excelFullPath; string savePath = EditorUtils.DataPath + TablePath; Debug.Log(path + "\n" + savePath); if (EditorExcelTools.ExportTo(_tableType, excelInfo.excelFullPath, new[] { savePath })) { AssetDatabase.Refresh(); } }
private static void ExportExcel() { if (!Directory.Exists(ExcelPath)) { Directory.CreateDirectory(ExcelPath); } var files = Directory.GetFiles(ExcelPath, "*.*", SearchOption.TopDirectoryOnly) .Where(p => p.EndsWith(".xlsx") || p.EndsWith(".xls")) .Select(p => new { path = p, name = Path.GetFileNameWithoutExtension(p), list = Path.GetFileNameWithoutExtension(p).Split('#') }) .Where(p => !p.name.StartsWith(".")) .ToLookup(p => p.list.First()) .ToDictionary(p => p.Key, p => p.ToList().Select(q => q.path).ToArray()); Debug.Log(files.Join("\n")); Debug.Log(JsonHelper.ToJson(files)); string csPath = EditorUtils.DataPath + ClassPath; if (!Directory.Exists(csPath)) { Directory.CreateDirectory(csPath); } foreach (KeyValuePair <string, string[]> pair in files) { foreach (string excelFullPath in pair.Value) { string classInfoName = pair.Key.Replace("Table", "Info"); string classTableName = pair.Key; EditorExcelTools.CreateClass(excelFullPath, classInfoName, classTableName, string.Format(csPath + "{0}.cs", classTableName)); string path = EditorUtils.DataPath + excelFullPath; string savePath = EditorUtils.DataPath + TablePath; Debug.Log(path + "\n" + savePath); EditorExcelTools.ExportTo(_tableType, excelFullPath, new[] { savePath }); } } AssetDatabase.Refresh(); }