Exemple #1
0
        /// <summary>
        /// 处理导出选项参数前事件
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public static void BeforeExporterOptionForm()
        {
            DataMemory.SetExportTotalCount(0);

            OptionsForm       optionForm = DataMemory.GetOptionsFrom();
            List <ExportType> typeList   = DataMemory.GetOptionsFromTypes();

            if (typeList.Count <= 0)
            {
                return;
            }
            if (optionForm.XlsxSrcPath.Length <= 0)
            {
                return;
            }
            if (optionForm.XlsxDstPath.Length <= 0)
            {
                return;
            }
            if (!Directory.Exists(optionForm.XlsxSrcPath))
            {
                return;
            }

            string[] files = Directory.GetFiles(optionForm.XlsxSrcPath, "*.xlsx", SearchOption.AllDirectories);
            if (files.Length <= 0)
            {
                return;
            }
            int count = 0;

            foreach (string srcFile in files)
            {
                string fileName = string.Empty;
                string xlsxName = Path.GetFileNameWithoutExtension(srcFile);
                fileName = xlsxName;
                foreach (ExportType type in typeList)
                {
                    string  outFileName = string.Format("{0}.{1}", fileName, type);
                    string  dstFile     = Path.Combine(optionForm.XlsxDstPath, outFileName);
                    Options option      = Options.ConvertToOption(srcFile, dstFile, type);
                    DataMemory.SetExportOption(type, option);
                    count++;
                }
            }

            DataMemory.SetExportTotalCount(count);
        }
Exemple #2
0
        private static void RunExporterAll()
        {
            List <ExportType> typeList = DataMemory.GetOptionsFromTypes();

            foreach (ExportType type in typeList)
            {
                ExporterAll all = new ExporterAll();
                all.OptionList = DataMemory.GetExportOptions(type);
                all.Coding     = Coding;
                all.ExpType    = type;
                all.OutPath    = GetExporterPath(type);

                all.Init();
                all.Process();
                all.Clear();
            }
        }
Exemple #3
0
        /// <summary>
        /// 根据窗口参数,执行Excel数据导出工作
        /// </summary>
        /// <param name="options">命令行参数</param>
        public static void RunXlsxForm(ExprotCallbackArgv argv)
        {
            if (argv == null)
            {
                throw new Exception("Run xlsx form argv is null.");
            }

            if (argv.OnRunChanged != null)
            {
                argv.OnRunChanged("=================开始导出=================");
            }

            int curreExportCount       = 0;
            List <ExportType> typeList = DataMemory.GetOptionsFromTypes();

            foreach (ExportType type in typeList)
            {
                List <Options> optionList = DataMemory.GetExportOptions(type);
                foreach (Options option in optionList)
                {
                    Options result = CmdXlsx(type, option);
                    if (argv.OnRunChanged != null)
                    {
                        argv.OnRunChanged(Options.ConvertToString(type, result));
                    }
                    curreExportCount++;
                    if (argv.OnProgressChanged != null)
                    {
                        argv.OnProgressChanged(curreExportCount);
                    }
                    Thread.Sleep(1);
                }
            }

            RunExporterAll();

            if (argv.OnRunChanged != null)
            {
                argv.OnRunChanged("=================导出完毕=================");
            }
        }