Reading Unknown Cell Values Best Practice

Nov 16, 2011 at 4:04 PM

Just wondering what people use as a best practice for reading cell values that are unknown whether or not they are formulas or straight values. It appears that we have both "Value" and "ValueCached" available for reading from cells, but what is the best way to use these to get an accurate value every time? "Value" will give me the formula if there is a formula in the cell, but the value if there is simply a value in the cell.  "ValueCached" will give me the value if there is a formula in the cell. Thoughts? 

Nov 16, 2011 at 4:41 PM

ClosedXML doesn't resolve formulas so the next best thing is to allow you to get the value calculated by Excel (ValueCached). Since the user can turn off automatic calculation of formulas the ValueCached property is on a "use at your own risk" basis. In other words, if you don't know for sure that the formulas have been calculated by Excel then don't use ValueCached. In this case you won't have the formula results.