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

New Post: Get formula's value

$
0
0
http://closedxml.codeplex.com/workitem/7614

I have try get the valuecached but its null sometimes.
And do u have a good way to get the value ? Thank U.
       object objValue = null;
            if (cell.HasFormula)
            {
                double tmpTime = 0;
             
                if (type.Equals(typeof(DateTime)) && Double.TryParse(cell.ValueCached, out tmpTime))
                    objValue = DateTime.FromOADate(Convert.ToDouble(cell.ValueCached));

                else
                {
                    try
                    {
                        objValue = cell.Value;
                    }
                    catch
                    {
                        objValue = cell.ValueCached;
                    }
                }
            }
            else
            {
                objValue = cell.Value;
            }
because when i got the cell.Value directly it will throw the exception .
I need your help.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



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