Example #1
0
        private void SetFormula(String formula, FormulaType formulaType)
        {
            IWorkbook wb = _row.Sheet.Workbook;

            if (formula == null)
            {
                ((XSSFWorkbook)wb).OnDeleteFormula(this);
                if (_cell.IsSetF())
                {
                    _cell.unsetF();
                }
                return;
            }

            IFormulaParsingWorkbook fpb = XSSFEvaluationWorkbook.Create(wb);

            //validate through the FormulaParser
            FormulaParser.Parse(formula, fpb, formulaType, wb.GetSheetIndex(this.Sheet), -1);

            CT_CellFormula f = new CT_CellFormula();

            f.Value = formula;
            _cell.f = (f);
            if (_cell.IsSetV())
            {
                _cell.unsetV();
            }
        }
Example #2
0
        public void RemoveFormula()
        {
            if (CellType == CellType.Blank)
            {
                return;
            }

            if (IsPartOfArrayFormulaGroup)
            {
                TryToDeleteArrayFormula(null);
                return;
            }
            ((XSSFWorkbook)_row.Sheet.Workbook).OnDeleteFormula(this);
            if (_cell.IsSetF())
            {
                ((XSSFSheet)_row.Sheet).OnDeleteFormula(this, null);
                _cell.unsetF();
            }
        }