public void ReadDataFromTemplate() { _State = State.TemplateLoading; try { if (!appSettings.Validate(out string errorMsg)) { _State = State.ErrorOccured; return; } string excelPath = appSettings.ExcelTemplateFilePath; FileInfo excelFile = new FileInfo(excelPath); StatusStringChanged(this, new StatusStringChangedArgs($"Template is loading: {excelPath}")); if (excelFile.Exists && excelFile.Extension.Equals(".xlsx")) { ds.Clean(); ExcelReader excelReader = new ExcelReader(excelPath); excelReader.ExceptionOccured += exception => { ExceptionOccured?.BeginInvoke(exception, null, null); }; excelReader.ReadData(ds); } else { throw new Exception($"Файл шаблона ({excelPath}) не существует или его раширение ({excelFile.Extension}) не .xlsx"); } } catch (Exception ex) { _State = State.ErrorOccured; StatusStringChanged(this, new StatusStringChangedArgs("Error occured")); throw ex; } StatusStringChanged(this, new StatusStringChangedArgs("Template loaded successfully")); _State = State.TemplateLoaded; }