コード例 #1
0
        public static void GenProtoBufClass(string excelPath, string finalPath)
        {
            ParseXlsx.OpenExcelApplication();
            Excel._Worksheet sheet = ParseXlsx.OpenExcelWorkBook(excelPath).OpenExcelSheet();

            string className = sheet.Name;

            CodeCompileUnit unit         = new CodeCompileUnit();
            CodeNamespace   theNamespace = new CodeNamespace("ResetCore.Data.Protobuf");

            unit.Namespaces.Add(theNamespace);
        }
コード例 #2
0
        public static void GenXmlAndGameData(string excelPath, string localGameDataXmlPath, string localGameDataClassPath)
        {
            GameDataGener.localGameDataXmlPath   = localGameDataXmlPath;
            GameDataGener.localGameDataClassPath = localGameDataClassPath;

            if (!Directory.Exists(excelPath))
            {
                Directory.CreateDirectory(excelPath);
            }
            if (!Directory.Exists(localGameDataXmlPath))
            {
                Directory.CreateDirectory(localGameDataXmlPath);
            }
            if (!Directory.Exists(localGameDataClassPath))
            {
                Directory.CreateDirectory(localGameDataClassPath);
            }

            DirectoryInfo dirInfo = new DirectoryInfo(excelPath);

            FileInfo[] fileInfos = dirInfo.GetFiles();

            ParseXlsx.OpenExcelApplication();
            try
            {
                foreach (FileInfo info in fileInfos)
                {
                    if (info.Extension == ".xlsx" && !info.Name.StartsWith("~$"))
                    {
                        Console.WriteLine("读取Excel" + info.FullName);
                        Excel._Worksheet sheet = ParseXlsx.OpenExcelWorkBook(info.FullName).OpenExcelSheet();
                        CreateNewXmls(Path.GetFileNameWithoutExtension(info.Name) + ".xml", sheet);
                        Console.WriteLine();
                    }
                }
                CreateNewClasses();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + " " + e.StackTrace);
            }
            finally
            {
                ParseXlsx.CloseExcelApplication();
            }
        }