示例#1
0
        private static void Main(string[] args)
        {
            /*
             * excelio --file=<file>.xls(x|m)
             */
            var parser     = new ArgumentParser();
            var parameters = parser.Parse(args);

            try
            {
                var validator = new ParameterValidator();
                validator.Validate(parameters);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Initialize();

            var folder = Path.GetDirectoryName(parameters.GetFullExcelFilePath());
            var files  = Directory.GetFiles(folder, "*.xlsx");

            var outputFolder = parameters.GetOutputPath();

            if (Directory.Exists(outputFolder))
            {
                Directory.Delete(outputFolder, true);
            }

            foreach (var file in files)
            {
                var workbook = ExcelFile.Load(file);
                var reader   = ExcelReaderFactory.Create((int)parameters[ArgumentParser.FileFormat], workbook);

                if (null != reader)
                {
                    PersistParticipantInfo(reader, outputFolder);
                }
            }

            CreateExportFiles(outputFolder, parameters.ShouldRandomize());

            Console.WriteLine("All files read. Press any key to exit!");
            Console.ReadLine();
        }