public void ApplyAnalysisAndSaveData( ExcelContextForPhaseTwo <IAnalysisPhaseTwo> excelContext) { excelContext.ThrowIfNull(nameof(excelContext)); using IExcelWorkbook workbook = ExcelHelper.GetOrCreateWorkbook(excelContext.OutputExcelFile); IExcelSheet sheet = workbook.GetOrCreateSheet(excelContext.SheetName); int currentColumnIndex = FillSheetHeader(sheet, excelContext.Args); IAnalysisPhaseTwo analysis = excelContext.CreateAnalysis(); analysis.ApplyAnalysisToDataset(sheet, currentColumnIndex); workbook.SaveToFile(excelContext.OutputExcelFile); excelContext.OutputExcelFile.Refresh(); }
public void ApplyAnalysisAndSaveDataOneIteration(IEnumerable <int> data, ExcelContextForPhaseTwo <IAnalysisPhaseTwo> excelContext, string dataFilename) { data.ThrowIfNullOrEmpty(nameof(data)); excelContext.ThrowIfNull(nameof(excelContext)); dataFilename.ThrowIfNullOrWhiteSpace(nameof(dataFilename)); using IExcelWorkbook workbook = ExcelHelper.GetOrCreateWorkbook(excelContext.OutputExcelFile); IExcelSheet sheet = workbook.GetOrCreateSheet(excelContext.SheetName); IAnalysisPhaseTwo analysis = excelContext.CreateAnalysis(); int iterationNumber = excelContext.Args.GetNumberOfIterationByFilename(dataFilename); var currentColumn = iterationNumber.AsEnum <ExcelColumnIndex>(); int rowCounter = GetFirstDataRowIndex(); foreach (int item in data) { int currentRow = rowCounter++; sheet[currentColumn, currentRow].SetValue(item); analysis.ApplyAnalysisToSingleLaunch(sheet, currentColumn, currentRow, item); } if (rowCounter - 1 != GetLastDataRowIndex(excelContext.Args)) { string message = "Too much data. Exceeded predefined place."; throw new ArgumentException(message, nameof(data)); } workbook.SaveToFile(excelContext.OutputExcelFile); excelContext.OutputExcelFile.Refresh(); }