Beispiel #1
0
        // Insert cell, which must be Formula, as array formula
        // in area ((ulCol,ulRow), (lrCol, lrRow))
        public void SetArrayFormula(Cell cell, int col, int row, CellAddr ulCa, CellAddr lrCa)
        {
            Formula formula = cell as Formula;

            if (cell == null)
            {
                throw new Exception("Invalid array formula");
            }
            else
            {
                CachedArrayFormula caf = new CachedArrayFormula(formula, this, col, row, ulCa, lrCa);
                // Increase support sets of cells referred by formula
                formula.AddToSupportSets(this, col, row, 1, 1);
                Interval displayCols = new Interval(ulCa.col, lrCa.col),
                         displayRows = new Interval(ulCa.row, lrCa.row);
                // The underlying formula supports (only) the ArrayFormula cells in display range
                formula.ResetSupportSet();
                formula.AddSupport(this, col, row, this, displayCols, displayRows);
                int cols = lrCa.col - ulCa.col + 1, rows = lrCa.row - ulCa.row + 1;
                for (int c = 0; c < cols; c++)
                {
                    for (int r = 0; r < rows; r++)
                    {
                        this[ulCa.col + c, ulCa.row + r] = new ArrayFormula(caf, c, r);
                    }
                }
            }
        }