Ejemplo n.º 1
0
        public override void AddMergedRegion(
            ExcelColumnIndex firstColumnIndex,
            int firstRowIndex,
            ExcelColumnIndex lastColumnIndex,
            int lastRowIndex)
        {
            int firstColumIndexInt = firstColumnIndex.AsInt32();

            firstColumIndexInt.ThrowIfValueIsOutOfRange(nameof(firstColumnIndex), 0, int.MaxValue);
            firstRowIndex.ThrowIfValueIsOutOfRange(nameof(firstRowIndex), 1, int.MaxValue);

            int lastColumIndexInt = lastColumnIndex.AsInt32();

            lastColumIndexInt.ThrowIfValueIsOutOfRange(nameof(lastColumnIndex), 0, int.MaxValue);
            lastRowIndex.ThrowIfValueIsOutOfRange(nameof(lastRowIndex), 1, int.MaxValue);

            var cra = new CellRangeAddress(
                firstRow: firstRowIndex - 1, // Because of using one-based indexing.
                lastRow: lastRowIndex - 1,   // Because of using one-based indexing.
                firstCol: firstColumIndexInt,
                lastCol: lastColumIndexInt
                );

            _sheet.AddMergedRegion(cra);
        }
Ejemplo n.º 2
0
        public void SetCenterizedCellFormula(ExcelColumnIndex columnIndex, int rowIndex,
                                             string formula)
        {
            formula.ThrowIfNullOrWhiteSpace(nameof(formula));

            GetOrCreateCenterizedCell(columnIndex, rowIndex).SetFormula(formula);
        }
        public override void AutoSizeColumn(ExcelColumnIndex columnIndex)
        {
            int columnIndexInt = columnIndex.AsInt32().UseOneBasedIndexing();

            columnIndexInt.ThrowIfValueIsOutOfRange(nameof(columnIndex), 1, int.MaxValue);

            _sheet.Column(columnIndexInt).AutoFit();
        }
Ejemplo n.º 4
0
        public override void AutoSizeColumn(ExcelColumnIndex columnIndex, bool useMergedCells)
        {
            int columnIndexInt = columnIndex.AsInt32();

            columnIndexInt.ThrowIfValueIsOutOfRange(nameof(columnIndex), 1, int.MaxValue);

            _sheet.AutoSizeColumn(columnIndexInt, useMergedCells);
        }
        public override void AutoSizeColumn(ExcelColumnIndex columnIndex, bool useMergedCells)
        {
            int columnIndexInt = columnIndex.AsInt32().UseOneBasedIndexing();

            columnIndexInt.ThrowIfValueIsOutOfRange(nameof(columnIndex), 1, int.MaxValue);

            // TODO: find a way to enable auto size for merged cells.
            _sheet.Column(columnIndexInt).AutoFit();
        }
        public BetaDistributionAnalysisPhaseTwo(ParametersPack args, IRegression regression)
        {
            _args       = args.ThrowIfNull(nameof(args));
            _regression = regression.ThrowIfNull(nameof(regression));

            _iterationsNumber         = args.GetIterationsNumber(phaseNumber: 2);
            _lastSegmentValueRowIndex = _iterationsNumber.SkipHeader();
            _additionalDataColumn     = ExcelWrapperForPhaseTwo.GetAdditionalDataColumn(_iterationsNumber);
            _sampleSizeColumnIndex    = ExcelWrapperForPhaseTwo.GetSampleSizeColumn(_iterationsNumber);
            _theoreticalMinColumn     = ExcelWrapperForPhaseTwo.GetTheoreticalMinColumn(_iterationsNumber);
            _theoreticalMaxColumn     = ExcelWrapperForPhaseTwo.GetTheoreticalMaxColumn(_iterationsNumber);
            _alphaColumn = GetAlphaColumn();
            _betaColumn  = GetBetaColumn();
        }
        public override IExcelCellHolder GetOrCreateCell(ExcelColumnIndex columnIndex, int rowIndex,
                                                         bool centrized)
        {
            int columnIndexInt = columnIndex.AsInt32().UseOneBasedIndexing();

            columnIndexInt.ThrowIfValueIsOutOfRange(nameof(columnIndex), 1, int.MaxValue);
            rowIndex.ThrowIfValueIsOutOfRange(nameof(rowIndex), 1, int.MaxValue);

            ExcelRange excelRange = _sheet.Cells[rowIndex, columnIndexInt];

            excelRange = centrized
                ? excelRange.Center()
                : excelRange;

            return(new EpplusExcelCellHolder(excelRange));
        }
        private IModelledFunction GetOptimalFunction(IExcelSheet sheet,
                                                     ExcelColumnIndex yColumnIndex)
        {
            var xValues = new List <double>(_iterationsNumber);
            var yValues = new List <double>(_iterationsNumber);

            for (int rowIndex = 1.SkipHeader(); rowIndex <= _lastSegmentValueRowIndex; ++rowIndex)
            {
                IExcelCellHolder sampleSizeCell = sheet[_sampleSizeColumnIndex, rowIndex];
                xValues.Add(sampleSizeCell.NumericValue);

                IExcelCellValueHolder yValueCell = sheet.EvaluateCell(yColumnIndex, rowIndex);
                yValues.Add(yValueCell.NumericValue);
            }

            return(_regression.Fit(xValues, yValues));
        }
        public static IExcelCellHolder GetCellHolder(IExcelSheet sheet,
                                                     ExcelColumnIndex columnIndex, int rowIndex, ReportOptions excelOptions)
        {
            sheet.ThrowIfNull(nameof(sheet));
            excelOptions.ThrowIfNull(nameof(excelOptions));

            return(excelOptions.CellCreationMode switch
            {
                ExcelCellCreationMode.Default =>
                sheet.GetOrCreateCell(columnIndex, rowIndex),

                ExcelCellCreationMode.Centerized =>
                sheet.GetOrCreateCenterizedCell(columnIndex, rowIndex),

                _ => throw new ArgumentOutOfRangeException(
                    nameof(excelOptions), excelOptions.CellCreationMode,
                    $"Unknown cell creation mode: '{excelOptions.CellCreationMode.ToString()}'."
                    )
            });
        public void ApplyAnalysisToSingleLaunch(IExcelSheet sheet, ExcelColumnIndex currentColumn,
                                                int currentRow, int operationNumber)
        {
            string dataAddress = sheet[currentColumn, currentRow].Address;

            int    theoreticalDataRow    = currentColumn.AsInt32().UseOneBasedIndexing().SkipHeader();
            string theoreticalMinAddress = sheet[_theoreticalMinColumn, theoreticalDataRow].Address;
            string theoreticalMaxAddress = sheet[_theoreticalMaxColumn, theoreticalDataRow].Address;

            string normalizedFormula = ManualFormulaProvider.Normalize(
                dataAddress, theoreticalMinAddress, theoreticalMaxAddress
                );

            int normalizedDataRowIndex = ExcelWrapperForPhaseTwo.GetNormalizedDataRowIndex(
                _args, currentRow
                );

            sheet[currentColumn, normalizedDataRowIndex].SetFormula(normalizedFormula);
        }
Ejemplo n.º 11
0
        public override void AddMergedRegion(
            ExcelColumnIndex firstColumnIndex,
            int firstRowIndex,
            ExcelColumnIndex lastColumnIndex,
            int lastRowIndex)
        {
            int firstColumnIndexInt = firstColumnIndex.AsInt32().UseOneBasedIndexing();

            firstColumnIndexInt.ThrowIfValueIsOutOfRange(nameof(firstRowIndex), 1, int.MaxValue);
            firstRowIndex.ThrowIfValueIsOutOfRange(nameof(firstRowIndex), 1, int.MaxValue);

            int lastColumnIndexInt = lastColumnIndex.AsInt32().UseOneBasedIndexing();

            lastColumnIndexInt.ThrowIfValueIsOutOfRange(nameof(lastRowIndex), 1, int.MaxValue);
            lastRowIndex.ThrowIfValueIsOutOfRange(nameof(lastRowIndex), 1, int.MaxValue);

            _sheet.Cells[
                firstRowIndex, firstColumnIndexInt,
                lastRowIndex, lastColumnIndexInt
            ].Merge = true;
        }
Ejemplo n.º 12
0
        public override IExcelCellHolder GetOrCreateCell(ExcelColumnIndex columnIndex, int rowIndex,
                                                         bool centrized)
        {
            rowIndex.ThrowIfValueIsOutOfRange(nameof(rowIndex), 1, int.MaxValue);
            int columIndexInt = columnIndex.AsInt32();

            columIndexInt.ThrowIfValueIsOutOfRange(nameof(columnIndex), 0, int.MaxValue);

            // Because of using one-based indexing.
            int  fixedRowIndex = rowIndex - 1;
            IRow row           = GetOrCreateRow(fixedRowIndex, centrized);

            ICell cell = row.GetCell(columIndexInt);

            ICell result = cell is null
                ? row.CreateCell(columIndexInt)
                : cell;

            result = centrized
                ? result.Center()
                : result;

            return(new NpoiExcelCellHolder(result));
        }
Ejemplo n.º 13
0
        public override void SetArrayFormula(
            string arrayFormula,
            ExcelColumnIndex firstColumnIndex,
            int firstRowIndex,
            ExcelColumnIndex lastColumnIndex,
            int lastRowIndex)
        {
            arrayFormula.ThrowIfNullOrWhiteSpace(nameof(arrayFormula));

            int firstColumnIndexInt = firstColumnIndex.AsInt32().UseOneBasedIndexing();

            firstColumnIndexInt.ThrowIfValueIsOutOfRange(nameof(firstRowIndex), 1, int.MaxValue);
            firstRowIndex.ThrowIfValueIsOutOfRange(nameof(firstRowIndex), 1, int.MaxValue);

            int lastColumnIndexInt = lastColumnIndex.AsInt32().UseOneBasedIndexing();

            lastColumnIndexInt.ThrowIfValueIsOutOfRange(nameof(lastRowIndex), 1, int.MaxValue);
            lastRowIndex.ThrowIfValueIsOutOfRange(nameof(lastRowIndex), 1, int.MaxValue);

            _sheet.Cells[
                firstRowIndex, firstColumnIndexInt,
                lastRowIndex, lastColumnIndexInt
            ].CreateArrayFormula(arrayFormula);
        }
Ejemplo n.º 14
0
 public abstract void AddMergedRegion(
     ExcelColumnIndex firstColumnIndex,
     int firstRowIndex,
     ExcelColumnIndex lastColumnIndex,
     int lastRowIndex);
Ejemplo n.º 15
0
 public abstract void AutoSizeColumn(ExcelColumnIndex columnIndex, bool useMergedCells);
Ejemplo n.º 16
0
 public abstract void SetArrayFormula(
     string arrayFormula,
     ExcelColumnIndex firstColumnIndex,
     int firstRowIndex,
     ExcelColumnIndex lastColumnIndex,
     int lastRowIndex);
Ejemplo n.º 17
0
 public IExcelCellHolder this[ExcelColumnIndex columnIndex, int rowIndex] =>
 ExcelWrapperHelper.GetCellHolder(this, columnIndex, rowIndex, _excelOptions);
Ejemplo n.º 18
0
 public abstract IExcelCellHolder GetOrCreateCell(ExcelColumnIndex columnIndex, int rowIndex,
                                                  bool centrized);
Ejemplo n.º 19
0
 public IExcelCellHolder GetOrCreateCenterizedCell(ExcelColumnIndex columnIndex, int rowIndex)
 {
     return(GetOrCreateCell(columnIndex, rowIndex, centrized: true));
 }
Ejemplo n.º 20
0
 public abstract void AutoSizeColumn(ExcelColumnIndex columnIndex);
Ejemplo n.º 21
0
 public IExcelCellValueHolder EvaluateCell(ExcelColumnIndex columnIndex, int rowIndex)
 {
     return(this[columnIndex, rowIndex].Evaluate());
 }
Ejemplo n.º 22
0
 public void SetCellValue(ExcelColumnIndex columnIndex, int rowIndex, double value)
 {
     GetOrCreateCell(columnIndex, rowIndex).SetValue(value);
 }
Ejemplo n.º 23
0
 public void SetCenterizedCellValue(ExcelColumnIndex columnIndex, int rowIndex,
                                    DateTime value)
 {
     GetOrCreateCenterizedCell(columnIndex, rowIndex).SetValue(value);
 }