Example #1
0
        /**
         * update cell references when Shifting rows
         *
         * @param n the number of rows to move
         */
        internal void Shift(int n)
        {
            int rownum = RowNum + n;
            CalculationChain calcChain = ((XSSFWorkbook)_sheet.Workbook).GetCalculationChain();
            int    sheetId             = (int)_sheet.sheet.sheetId;
            String msg = "Row[rownum=" + RowNum + "] contains cell(s) included in a multi-cell array formula. " +
                         "You cannot change part of an array.";

            foreach (ICell c in this)
            {
                XSSFCell cell = (XSSFCell)c;
                if (cell.IsPartOfArrayFormulaGroup)
                {
                    cell.NotifyArrayFormulaChanging(msg);
                }

                //remove the reference in the calculation chain
                if (calcChain != null)
                {
                    calcChain.RemoveItem(sheetId, cell.GetReference());
                }

                CT_Cell CT_Cell = cell.GetCTCell();
                String  r       = new CellReference(rownum, cell.ColumnIndex).FormatAsString();
                CT_Cell.r = r;
            }
            RowNum = rownum;
        }
Example #2
0
        internal void Shift(int n)
        {
            int pRow = this.RowNum + n;
            CalculationChain calculationChain = ((XSSFWorkbook)this._sheet.Workbook).GetCalculationChain();
            int    sheetId = (int)this._sheet.sheet.sheetId;
            string msg     = "Row[rownum=" + (object)this.RowNum + "] contains cell(s) included in a multi-cell array formula. You cannot change part of an array.";

            foreach (XSSFCell xssfCell in this)
            {
                if (xssfCell.IsPartOfArrayFormulaGroup)
                {
                    xssfCell.NotifyArrayFormulaChanging(msg);
                }
                calculationChain?.RemoveItem(sheetId, xssfCell.GetReference());
                xssfCell.GetCTCell().r = new CellReference(pRow, xssfCell.ColumnIndex).FormatAsString();
            }
            this.RowNum = pRow;
        }