private void OnConvertClick(Income income) { _income = income; Global.Instance.CurrentType = _income.Type; _view.ConvertButtonEnabled = false; _view.StopButtonEnabled = true; _excelConverter = new ExcelConverter(income.Type); _excelConverter.SetProgressBarValue += Converter_SetProgressBarValue; _excelConverter.PrintStatus += ExcelCommander_PrintStatus; _excelConverter.PrintMessage += _view.PrintLog; _excelConverter.OperationCompleted += Converter_OperationCompleted; _backgroundWorker = new BackgroundWorker() {WorkerSupportsCancellation = true}; _backgroundWorker.DoWork += _backgroundWorker_DoWork; _backgroundWorker.RunWorkerAsync(); }
public static void Test() { //Income testIncome = new Income() //{ // FilePath = @"e:\Projects\SportproConverter\Docs\Test\Склад03.08.2015.xls", // Type = Global.Instance.IncomeFileTypes.Find(t => t.Id == 1) //}; Income testDinamo = new Income() { FilePath = @"e:\Projects\SportproConverter\Docs\Test\Остатки ДИНАМО.xlsx", Type = Global.Instance.IncomeFileTypes.Find(t => t.Description == "Динамо") }; IExcelConverter converter = new ExcelConverter(testDinamo.Type); converter.Convert(testDinamo); converter.CloseApp(); }
public void Convert(Income income) { try { PrintMessage?.Invoke("Открываем файл"); ExcelCommander.OpenFile(income); PrintMessage?.Invoke("Обработка..."); ExcelCommander.Parse(); PrintMessage?.Invoke("Выгружаем"); ExcelCommander.Export(); PrintMessage?.Invoke("Готово!"); OperationCompleted?.Invoke(new RunWorkerCompletedEventArgs(null, null, false)); } catch (Exception exception) { OperationCompleted?.Invoke(new RunWorkerCompletedEventArgs(null, exception, true)); } }
public void OpenFile(Income income) { App = new Application {Visible = false}; Income = income; Workbook = App.Workbooks.Open(income.FilePath); ActiveWorksheet = Workbook.ActiveSheet; }