Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Named Constants

$
0
0
Hello:

I have a fairly simple question. I am using ClosedXML in one of my projects. I just found out that ClosedXML can actually evaluate formulas after doing a simple search. What I have been doing until now is using Excel interop to evaluate the formulas using a PasteSpecial then using ClosedXML to read the results from a temporary sheet.

I am using very simple formulas, essentially Cell1 + Cell2 * Cell3, etc. and maybe some of the basic built in Excel functions. I know in the past that ClosedXML relied on the ValueCached property for values to be returned. I do not want to rely on this ValueCached, because 99% of the time it is not there. This does not seem to be an issue now.

My question is this: If I define a named constant, for example A4 = 1 and then in Excel define it as "constant", can ClosedXML then evaluate the formula using named constants? What about complex named constants (A4 + A5 + A6 / A1) = "constant)? Another cell then has the formula: B2 + B5 + constant. It seems as though ClosedXML is evaluating this, because if I then go get the cell using ClosedXML, the value is correct; HOWEVER, I notice that the "ValueCached" property is filled in with the same value. Is ClosedXML relying on value cached in this case that may or may not be there for some cells? Like I said, I do not want to rely on ValueCached. I want the formulas to be evaluate every time no matter what I throw at it. I realize not all Excel functions are supported; that is a given. Will ClosedXML evaluate every time with the simple formulas I am giving it?

If ClosedXML does not support this case, I understand and will subsequently stay away from named constants since I can just reference the actual cell. I just know that a bunch of the guys I work with happen to like named constants, because they are much easier to reference in multiple pages.

Thanks,

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>