示例#1
0
        public override Ptg[] GetFormulaTokens(IEvaluationCell evalCell)
        {
            XSSFCell cell       = ((XSSFEvaluationCell)evalCell).GetXSSFCell();
            int      sheetIndex = _uBook.GetSheetIndex(cell.Sheet);
            int      rowIndex   = cell.RowIndex;

            return(FormulaParser.Parse(cell.GetCellFormula(this), this, FormulaType.Cell, sheetIndex, rowIndex));
        }
示例#2
0
文件: XSSFCell.cs 项目: founshi/npoi
        /**
         * package/hierarchy use only - reuse an existing evaluation workbook if available for caching
         *
         * @param fpb evaluation workbook for reuse, if available, or null to create a new one as needed
         * @return a formula for the cell
         * @throws InvalidOperationException if the cell type returned by {@link #getCellType()} is not CELL_TYPE_FORMULA
         */
        protected internal String GetCellFormula(XSSFEvaluationWorkbook fpb)
        {
            CellType cellType = CellType;

            if (cellType != CellType.Formula)
            {
                throw TypeMismatch(CellType.Formula, cellType, false);
            }

            CT_CellFormula f = _cell.f;

            if (IsPartOfArrayFormulaGroup && f == null)
            {
                XSSFCell cell = ((XSSFSheet)Sheet).GetFirstCellInArrayFormula(this);
                return(cell.GetCellFormula(fpb));
            }
            if (f.t == ST_CellFormulaType.shared)
            {
                //return ConvertSharedFormula((int)f.si);
                return(ConvertSharedFormula((int)f.si, fpb == null ? XSSFEvaluationWorkbook.Create(Sheet.Workbook) : fpb));
            }
            return(f.Value);
        }