EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

`Calculate()` produces the error '#VALUE!' when it references a cell whose `Value` is a .NET `float` - `double` works fine

Open slawomir-brzezinski-at-clarksons opened this issue 6 years ago • 2 comments
trafficstars

(Forgive the brief info, but this is also on a busy project, while there is a chance this can be fixed outright. Do advise if this is not the case and we will try to fill more info in.)

Our scenario:

Out of incidence, some of our source data-structures hold some of the numbers as the 'single-precision' float and some in double. Whenever a formula refers to a cell whose .Value was set to a float, it causes that formula to not be properly computed using the calls to Calculate(). Excel can compute them just fine, but it doesn't run any calculations for files downloaded from internet until the user decides to disable the 'Protected View'.

Fix?

This seems to me just a simple omission of the float data type in this if condition (it already conflates double and decimal together).

P.S. This might also be a common cause to this issue, but not sure.

I have not been able to reproduce an error due to a cell value set with a float. It is omitted in the if condition you are refering to, but that does not seem to change anything since floats are handled via the TypeCompat.IsPrimitive condition in IsNumeric function and the regex in the IsNumericString function, both in the ExcelFunction class. I wrote a reply to the other issue about floating pont precision.

Best,

Mats

swmal avatar Feb 08 '20 22:02 swmal

Hi. Thanks for the reply.

Regarding the TypeCompat, I haven't got a clue, but I'm really certain that this "Non supported type" exception was hitting (the exception is not propagated to caller of Calculate, but it can be seen by connecting with a debugger and selecting to break on 'caught exception'), so certainly making this not happen by adding a float support to the CompileResultFactory, which already lists different numeric subtypes but misses the float, seems like an obvious thing to do.

In any case, our project has also moved on now so unfortunately I won't be able to help re-reproduce. Regards.