Beispiel #1
0
        private static void exportFile(string excelPath, string outputDir, TableExportFormat fmt)
        {
            var data = TableExcelReader.loadFromExcel(excelPath);

            switch (fmt)
            {
            case TableExportFormat.Dat:
            {
                var exportPath = Path.Combine(outputDir, string.Format("{0}.exdat", Path.GetFileNameWithoutExtension(excelPath)));
                TableExcelExportDat.exportExcelFile(data, exportPath);
            }
            break;

            case TableExportFormat.Json:
            {
                var exportPath = Path.Combine(outputDir, string.Format("{0}.json", Path.GetFileNameWithoutExtension(excelPath)));
                TableExcelExportJson.exportExcelFile(data, exportPath);
            }
            break;

            case TableExportFormat.Xml:
            {
                var exportPath = Path.Combine(outputDir, string.Format("{0}.xml", Path.GetFileNameWithoutExtension(excelPath)));
                TableExcelExportXml.exportExcelFile(data, exportPath);
            }
            break;

            case TableExportFormat.Lua:
            {
                var exportPath = Path.Combine(outputDir, string.Format("{0}.lua", Path.GetFileNameWithoutExtension(excelPath)));
                TableExcelExportLua.exportExcelFile(data, exportPath);
            }
            break;
            }
        }
Beispiel #2
0
        private void _genSingleFileImpl(string filePath, string exportDir, TableExportFormat fmt)
        {
            Log.Msg("正在分析 {0}", filePath);
            try
            {
                TableExcelData data = TableExcelReader.loadFromExcel(filePath);
                string         errmsg;
                if (!data.checkUnique(out errmsg))
                {
                    Log.Wrn(errmsg);
                }
                switch (fmt)
                {
                case TableExportFormat.Json:
                {
                    var exportPath = Path.Combine(exportDir, string.Format("{0}.json", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportJson.exportExcelFile(data, exportPath);
                }
                break;

                    /*
                     * case TableExportFormat.Dat:
                     * {
                     *  var exportPath = Path.Combine(exportDir, string.Format("{0}.exdat", Path.GetFileNameWithoutExtension(filePath)));
                     *  TableExcelExportDat.exportExcelFile(data, exportPath);
                     * }
                     * break;
                     * case TableExportFormat.Xml:
                     * {
                     *  var exportPath = Path.Combine(exportDir, string.Format("{0}.xml", Path.GetFileNameWithoutExtension(filePath)));
                     *  TableExcelExportXml.exportExcelFile(data, exportPath);
                     * }
                     * break;
                     * case TableExportFormat.Lua:
                     * {
                     *  var exportPath = Path.Combine(exportDir, string.Format("{0}.lua", Path.GetFileNameWithoutExtension(filePath)));
                     *  TableExcelExportLua.exportExcelFile(data, exportPath);
                     * }
                     * break;
                     */
                }
                //生成.h文件
                {
                    var exportPath = Path.Combine(exportDir, string.Format("{0}.h", Path.GetFileNameWithoutExtension(filePath)));
                    var outCppData = CreateTableCpp.toFileData(Path.GetFileNameWithoutExtension(filePath), data.Headers);
                    File.WriteAllBytes(exportPath, Encoding.UTF8.GetBytes(outCppData));
                }

                Log.Msg("生成成功");
            }
            catch (System.Exception ex)
            {
                Log.Err(ex.Message);
            }
        }
Beispiel #3
0
 public static void processOpenExcelFile()
 {
     try
     {
         var data = TableExcelReader.loadFromExcel(OpenExcelFullPath);
         openEditUI(data, OpenExcelFullPath);
     }
     catch (System.Exception ex)
     {
         MsgBox(ex.Message);
     }
 }
        private void _genSingleFileImpl(string filePath, string exportDir, TableExportFormat fmt)
        {
            Log.Msg("正在分析 {0}", filePath);
            try
            {
                TableExcelData data = TableExcelReader.loadFromExcel(filePath);
                string         errmsg;
                if (!data.checkUnique(out errmsg))
                {
                    Log.Wrn(errmsg);
                }
                switch (fmt)
                {
                case TableExportFormat.Dat:
                {
                    var exportPath = Path.Combine(exportDir, string.Format("{0}.exdat", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportDat.exportExcelFile(data, exportPath);
                }
                break;

                case TableExportFormat.Json:
                {
                    var exportPath = Path.Combine(exportDir, string.Format("{0}.json", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportJson.exportExcelFile(data, exportPath);
                }
                break;

                case TableExportFormat.Xml:
                {
                    var exportPath = Path.Combine(exportDir, string.Format("{0}.xml", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportXml.exportExcelFile(data, exportPath);
                }
                break;

                case TableExportFormat.Lua:
                {
                    var exportPath = Path.Combine(exportDir, string.Format("{0}.lua", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportLua.exportExcelFile(data, exportPath);
                }
                break;
                }
                Log.Msg("生成成功");
            }
            catch (System.Exception ex)
            {
                Log.Err(ex.Message);
            }
        }
Beispiel #5
0
        public void editForExcel(string filePath)
        {
            if (!File.Exists(filePath))
            {
                Log.Err("源文件不存在! {0}", filePath);
                return;
            }

            try
            {
                TableExcelData data = TableExcelReader.loadFromExcel(filePath);
                openExcelView(data, filePath);
            }
            catch (System.Exception ex)
            {
                Log.Err(ex.Message);
            }
        }
Beispiel #6
0
        public void rectifyFileFormat(string filePath)
        {
            if (!File.Exists(filePath))
            {
                Log.Err("源文件不存在! {0}", filePath);
                return;
            }

            Log.Msg("=================================================");

            try
            {
                Log.Msg("正在优化 {0}", filePath);
                TableExcelData data = TableExcelReader.loadFromExcel(filePath);
                TableExcelWriter.genExcel(data, filePath);
                Log.Msg("优化完毕!");
            }
            catch (System.Exception ex)
            {
                Log.Err(ex.Message);
            }
        }
Beispiel #7
0
        public void rectifyAllFileFormat(List <string> files)
        {
            if (files.Count == 0)
            {
                Log.Wrn("没有要优化的文件");
                return;
            }

            Log.Msg("=================================================");
            foreach (var filePath in files)
            {
                try
                {
                    Log.Msg("正在优化 {0}", filePath);
                    TableExcelData data = TableExcelReader.loadFromExcel(filePath);
                    TableExcelWriter.genExcel(data, filePath);
                }
                catch (System.Exception ex)
                {
                    Log.Err(ex.Message);
                }
            }
            Log.Msg("优化完毕!");
        }
Beispiel #8
0
        private bool _genSingleFileImpl(string filePath, string exportDir, TableExportFormat fmt)
        {
            Log.Msg("----------正在导出 {0}----------", filePath);
            string exportPath = exportDir;

            try
            {
                TableExcelData data = TableExcelReader.loadFromExcel(filePath);
                string         errmsg;
                if (!data.checkUnique(out errmsg))
                {
                    throw new System.Exception(errmsg);
                }
                if (!data.checkDataType(out errmsg))
                {
                    throw new System.Exception(errmsg);
                }
                switch (fmt)
                {
                case TableExportFormat.Dat:
                {
                    exportPath = Path.Combine(exportDir, string.Format("{0}.exdat", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportDat.exportExcelFile(data, exportPath);
                }
                break;

                case TableExportFormat.Json:
                {
                    // export json
                    exportPath = Path.Combine(exportDir, string.Format("{0}.json", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportJson.exportExcelFile(data, exportPath);

                    // export cs
                    string fileName = Path.GetFileNameWithoutExtension(filePath);
                    fileName   = fileName.Substring(0, 1).ToUpper() + fileName.Substring(1);
                    exportPath = Path.Combine(exportDir, string.Format($"{ fileName }.cs"));
                    TableExcelExportCs.ExportExcelFile(data, exportPath);

                    // export csEx
                    exportPath = Path.Combine(exportDir, string.Format($"{ fileName }.Ex.cs"));
                    if (!File.Exists(exportPath))
                    {
                        TableExcelExportCsEx.ExportExcelFile(data, exportPath, fileName);
                    }
                }
                break;

                case TableExportFormat.Xml:
                {
                    exportPath = Path.Combine(exportDir, string.Format("{0}.xml", Path.GetFileNameWithoutExtension(filePath)));
                    TableExcelExportXml.exportExcelFile(data, exportPath);
                }
                break;

                case TableExportFormat.Lua:
                {
                    exportPath = Path.Combine(exportDir, string.Format("{0}.lua", Path.GetFileNameWithoutExtension(filePath)));
                    if (AppData.Config.FitUnity3D == true)
                    {
                        exportPath += ".txt";
                    }
                    TableExcelExportLua.exportExcelFile(data, exportPath);
                }
                break;
                }
                Log.Msg("----------导出成功 {0} ----------", exportPath);
                return(true);
            }
            catch (System.Exception ex)
            {
                Log.Err(ex.Message);
                Log.Err("----------导出失败 {0} ----------", exportPath);
                return(false);
            }
        }