EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

Sumsq issue

Open ghost opened this issue 5 years ago • 1 comments
trafficstars

EEPlus v: 4.5.3.3

The cell C1 contains this formula "SQRT(SUMSQ(B1:B300000)/ COUNTA(B1:B300000))". I'm trying to get C1 value after WS.Cells["C1"].Calculate() but I get following error:

=================================
Timestamp: 05/02/2020 17:48:55

Worksheet: test.csv
Address: C1
OfficeOpenXml.FormulaParsing.Exceptions.ExcelErrorValueException: #VALUE!
   at OfficeOpenXml.FormulaParsing.Excel.Functions.ExcelFunction.CheckForAndHandleExcelError(ICellInfo cell)
   at OfficeOpenXml.FormulaParsing.Excel.Functions.Math.Sumsq.Calculate(FunctionArgument arg, ParsingContext context, Boolean isInArray)
   at OfficeOpenXml.FormulaParsing.Excel.Functions.Math.Sumsq.Execute(IEnumerable`1 arguments, ParsingContext context)
   at OfficeOpenXml.FormulaParsing.ExpressionGraph.FunctionExpression.Compile()

=================================
Timestamp: 05/02/2020 17:48:55

Worksheet: test.csv
Address: C1
OfficeOpenXml.FormulaParsing.Exceptions.ExcelErrorValueException: #VALUE!
   at OfficeOpenXml.FormulaParsing.Excel.Functions.DoubleArgumentParser.Parse(Object obj)
   at OfficeOpenXml.FormulaParsing.Excel.Functions.ExcelFunction.ArgToDecimal(Object obj)

The formula in the cell is written without "=". if I open the file with excel after creation it's work. I tried to use WS.Cells.Calculate(), the others formulas work but not that. I tried to close and reopen the file, get value after Calculate() but the result is the same.

ghost avatar Feb 05 '20 06:02 ghost

Hi,

just a brief disclaimer: the bugs we are fixing now is in EPPlus 5, which has moved to another repo and is distributed under another license (see the readme file in the new repo).

In this case it is difficult to see what is going wrong without the underlying data. Somewhere during the calculation EPPlus seems to fail in converting one of the values in the ranges to a double. Since it seems to be during execution of the SUMSQ(B1:B300000) and the function throwing the exception is CheckForAndHandleExcelError the only thing I can say is that in one of these 300000 cells you have an error. Our implementation of Sumsq throws an exception if a cell within the range contains an error.

swmal avatar Feb 08 '20 22:02 swmal