nissl-lab / npoi

a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.
Apache License 2.0
5.73k stars 1.43k forks source link

Formula calculation exception #1279

Closed Leon-lu closed 8 months ago

Leon-lu commented 8 months ago

problem description

I am calculating formulas in excel workbook,The file format is xlsx

        try {
            var evaluator = NPOI.SS.UserModel.WorkbookFactory.CreateFormulaEvaluator(workbook);
            evaluator.EvaluateAll();
        }
        catch (Exception ex) { }

The exception is described as follows

System.InvalidOperationException: evaluation stack not empty 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateAny(IEvaluationCell srcCell, Int32 sheetIndex, Int32 rowIndex, Int32 columnIndex, EvaluationTracker tracker) 在 NPOI.SS.Formula.LazyRefEval.GetInnerValueEval(Int32 sheetIndex) 在 NPOI.SS.Formula.Eval.OperandResolver.GetSingleValue(ValueEval arg, Int32 srcCellRow, Int32 srcCellCol) 在 NPOI.SS.Formula.Eval.TwoOperandNumericOperation.Evaluate(Int32 srcRowIndex, Int32 srcColumnIndex, ValueEval arg0, ValueEval arg1) 在 NPOI.SS.Formula.Functions.Fixed2ArgFunction.Evaluate(ValueEval[] args, Int32 srcRowIndex, Int32 srcColumnIndex) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateAny(IEvaluationCell srcCell, Int32 sheetIndex, Int32 rowIndex, Int32 columnIndex, EvaluationTracker tracker) 在 NPOI.SS.Formula.LazyRefEval.GetInnerValueEval(Int32 sheetIndex) 在 NPOI.SS.Formula.Eval.OperandResolver.GetSingleValue(ValueEval arg, Int32 srcCellRow, Int32 srcCellCol) 在 NPOI.SS.Formula.Eval.TwoOperandNumericOperation.Evaluate(Int32 srcRowIndex, Int32 srcColumnIndex, ValueEval arg0, ValueEval arg1) 在 NPOI.SS.Formula.Functions.Fixed2ArgFunction.Evaluate(ValueEval[] args, Int32 srcRowIndex, Int32 srcColumnIndex) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateAny(IEvaluationCell srcCell, Int32 sheetIndex, Int32 rowIndex, Int32 columnIndex, EvaluationTracker tracker) 在 NPOI.SS.Formula.LazyRefEval.GetInnerValueEval(Int32 sheetIndex) 在 NPOI.SS.Formula.Eval.OperandResolver.GetSingleValue(ValueEval arg, Int32 srcCellRow, Int32 srcCellCol) 在 NPOI.SS.Formula.Eval.TwoOperandNumericOperation.Evaluate(Int32 srcRowIndex, Int32 srcColumnIndex, ValueEval arg0, ValueEval arg1) 在 NPOI.SS.Formula.Functions.Fixed2ArgFunction.Evaluate(ValueEval[] args, Int32 srcRowIndex, Int32 srcColumnIndex) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateAny(IEvaluationCell srcCell, Int32 sheetIndex, Int32 rowIndex, Int32 columnIndex, EvaluationTracker tracker) 在 NPOI.SS.Formula.LazyRefEval.GetInnerValueEval(Int32 sheetIndex) 在 NPOI.SS.Formula.Eval.OperandResolver.GetSingleValue(ValueEval arg, Int32 srcCellRow, Int32 srcCellCol) 在 NPOI.SS.Formula.WorkbookEvaluator.DereferenceResult(ValueEval evaluationResult, Int32 srcRowNum, Int32 srcColNum) 在 NPOI.SS.Formula.WorkbookEvaluator.DereferenceResult(ValueEval evaluationResult, OperationEvaluationContext ec) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs) 在 NPOI.SS.Formula.WorkbookEvaluator.EvaluateAny(IEvaluationCell srcCell, Int32 sheetIndex, Int32 rowIndex, Int32 columnIndex, EvaluationTracker tracker) 在 NPOI.SS.Formula.WorkbookEvaluator.Evaluate(IEvaluationCell srcCell) 在 NPOI.XSSF.UserModel.BaseXSSFFormulaEvaluator.EvaluateFormulaCellValue(ICell cell) 在 NPOI.SS.Formula.BaseFormulaEvaluator.Evaluate(ICell cell)

tonyqus commented 8 months ago

Please follow the bug report issue template.