コード例 #1
0
 private static void ToTxtAsset(string excelPath, string outputPath)
 {
     try
     {
         var book = EEWorkbook.Load(excelPath);
         if (book == null)
         {
             return;
         }
         foreach (var sheet in book.sheets)
         {
             if (sheet == null)
             {
                 continue;
             }
             if (!IsValidSheet(sheet))
             {
                 continue;
             }
             //var sheetData = ToSheetData(sheet);
             var sheetData = ToSheetDataRemoveEmptyColumn(sheet);
             ToTxtAsset(excelPath, sheet.name, outputPath, sheetData);
         }
     }
     catch (Exception e)
     {
         EELog.LogError(e.ToString());
         AssetDatabase.Refresh();
     }
 }
コード例 #2
0
ファイル: EEToCSharp.cs プロジェクト: end1220/XlsxUnity3D
        private static Dictionary <string, string> ToCSharpArray(string excelPath)
        {
            var lst  = new Dictionary <string, string>();
            var book = EEWorkbook.Load(excelPath);

            if (book == null)
            {
                return(lst);
            }
            foreach (var sheet in book.sheets)
            {
                if (sheet == null)
                {
                    continue;
                }
                if (!IsValidSheet(sheet))
                {
                    EELog.Log(string.Format("Skipped sheet {0} in file {1}.", sheet.name, excelPath));
                    continue;
                }
                var sheetData = ToSheetData(sheet);
                var csTxt     = ToCSharp(sheetData, sheet.name);
                lst.Add(sheet.name, csTxt);
            }
            return(lst);
        }
コード例 #3
0
        public static void OpenWithFile(string filePath)
        {
            try
            {
                if (string.IsNullOrEmpty(filePath))
                {
                    return;
                }
                var fullPath = filePath;
                if (!Path.IsPathRooted(filePath))
                {
                    if (filePath.StartsWith("Assets/"))
                    {
                        filePath = filePath.Substring("Assets/".Length);
                    }
                    fullPath = Path.Combine(Application.dataPath, filePath);
                }

                if (!File.Exists(fullPath))
                {
                    return;
                }
                var workbook = EEWorkbook.Load(fullPath);
                var window   = GetWindow <EEWorkbookEditor>(WindowName);
                window.Show();
                window.SetWorkbook(workbook);
            }
            catch (Exception e)
            {
                EELog.LogError(e.ToString());
            }
        }
コード例 #4
0
        private static Dictionary <string, string> ToCSharpInspectorArray(string excelPath)
        {
            var lst  = new Dictionary <string, string>();
            var book = EEWorkbook.Load(excelPath);

            if (book == null)
            {
                return(lst);
            }
            string fileName = Path.GetFileName(excelPath);

            foreach (var sheet in book.sheets)
            {
                if (sheet == null)
                {
                    continue;
                }
                if (!IsValidSheet(sheet))
                {
                    continue;
                }
                var csTxt = ToCSharpInspector(sheet.name, fileName);
                lst.Add(sheet.name, csTxt);
            }
            return(lst);
        }
コード例 #5
0
        private static Dictionary <string, string> ToGolangArray(string excelPath)
        {
            var lst  = new Dictionary <string, string>();
            var book = EEWorkbook.Load(excelPath);

            if (book == null)
            {
                return(lst);
            }
            string fileName = Path.GetFileName(excelPath);

            foreach (var sheet in book.sheets)
            {
                if (sheet == null)
                {
                    continue;
                }
                if (!IsValidSheet(sheet))
                {
                    EELog.Log(string.Format("Skipped sheet [{0}] in file <{1}>.", sheet.name, fileName));
                    continue;
                }
                var sheetData = ToSheetData(sheet);
                var csTxt     = ToGolang(sheetData, sheet.name, fileName);
                lst.Add(sheet.name, csTxt);
            }

            return(lst);
        }
コード例 #6
0
 public static void DrawTableTab(EEWorkbook file, ref int selectIndex)
 {
     GUILayout.BeginHorizontal();
     {
         for (var i = 0; i < file.sheets.Count; i++)
         {
             if (GUILayout.Toggle(selectIndex == i, file.sheets[i].name, EditorStyles.toolbarButton))
             {
                 selectIndex = i;
             }
         }
     }
     GUILayout.EndHorizontal();
 }
コード例 #7
0
ファイル: EEWorkbook.cs プロジェクト: end1220/XlsxUnity3D
 public static EEWorkbook Create(string firstSheetName = "Sheet 1")
 {
     try
     {
         using (var ep = new ExcelPackage())
         {
             ep.Workbook.Worksheets.Add(firstSheetName);
             var workbook = new EEWorkbook(ep.Workbook);
             return(workbook);
         }
     }
     catch (Exception e)
     {
         Debug.LogError(e.ToString());
         return(null);
     }
 }
コード例 #8
0
ファイル: EEWorkbook.cs プロジェクト: end1220/XlsxUnity3D
        public static EEWorkbook Load(string path)
        {
            try
            {
                var file = new FileInfo(path);
                using (var ep = new ExcelPackage(file))
                {
                    var workbook = new EEWorkbook(ep.Workbook);
                    return(workbook);
                }
            }
            catch (Exception e)
            {
                EELog.LogError(e.ToString());
            }

            return(null);
        }
コード例 #9
0
 private void SetWorkbook(EEWorkbook eeWorkbook)
 {
     _currentEeWorkbook = eeWorkbook;
     //Worksheet.SetCellTypeByColumn(1, CellType.Label);
     //Worksheet.SetCellTypeByColumn(3, CellType.Popup, new List<string> {"1", "2"});
 }