Exemplo n.º 1
0
        bool Export()
        {
            try
            {
                DateTime      start = DateTime.Now;
                List <string> readfiles;
                CustomWorkbook.Init(paths[0], out readfiles);
                if (readfiles.Count < 10)
                {
                    readfiles.ForEach(Console.WriteLine);
                }
                Console.WriteLine("读入" + readfiles.Count + "张表," +
                                  (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");

                start = DateTime.Now;
                if (!CheckError(Exporter.ReadDataXlsx()))
                {
                    return(false);
                }
                Console.WriteLine("读取xlsx, " + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");

                // * lua
                if (_isOutLua)
                {
                    start = DateTime.Now;
                    if (!CheckError(Exporter.ReadFormulaXlsx(Exporter.DealWithFormulaSheetLua)))
                    {
                        return(false);
                    }
                    Console.WriteLine("lua公式, " + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");

                    start = DateTime.Now;
                    if (!CheckError(Exporter.ExportLua(paths[1])))
                    {
                        return(false);
                    }
                    Console.WriteLine("导出lua文件," + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");
                }

                // * go
                if (_isOutGo)
                {
                    start = DateTime.Now;
                    if (!CheckError(Exporter.ReadFormulaXlsx(Exporter.DealWithFormulaSheetGo)))
                    {
                        return(false);
                    }
                    Console.WriteLine("go公式," + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");

                    start = DateTime.Now;
                    if (!CheckError(Exporter.ExportGo(paths[2], paths[3])))
                    {
                        return(false);
                    }
                    Console.WriteLine("导出go文件," + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");
                }

                // * c#
                if (_isOutCs)
                {
                    start = DateTime.Now;
                    if (!CheckError(Exporter.ReadFormulaXlsx(Exporter.DealWithFormulaSheetCS)))
                    {
                        return(false);
                    }
                    Console.WriteLine("c#公式," + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");

                    start = DateTime.Now;
                    if (!CheckError(Exporter.ExportCS(paths[4], paths[5])))
                    {
                        return(false);
                    }
                    Console.WriteLine("导出c#文件," + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");
                }

                // * typescript
                if (_isOutTs)
                {
                    start = DateTime.Now;
                    if (!CheckError(Exporter.ReadFormulaXlsx(Exporter.DealWithFormulaSheetTS)))
                    {
                        return(false);
                    }
                    Console.WriteLine("ts公式," + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");

                    start = DateTime.Now;
                    if (!CheckError(Exporter.ExportTS(paths[6], paths[7])))
                    {
                        return(false);
                    }
                    Console.WriteLine("导出ts文件," + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "秒");
                }

                Cache.SaveCache();
                Console.WriteLine("存储缓存");
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            return(false);
        }