Home » excel » c# – How to read from excel cell display value without evaluating formula with ClosedXML

c# – How to read from excel cell display value without evaluating formula with ClosedXML

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have an excel file and I want to import its data to a web application using ClosedXML.

Now I am using this to read a date as string:

var validFrom = ((DateTime)row.Cell("B").Value).ToString("d/M/yyyy");

and this to read a decimal as string:

var price = row.Cell(letter).Value.ToString();

In order for this to work I have to copy paste-as-values-only from excel and then import the file to my app. Formulas contain filepaths from remote excel files that are not accessible from the server or function that are not working with ClosedXML (such as VLOOKUP).

How can I read data as displayed without re-evaluating the formula?

How to&Answers:

You can use the cell.CachedValue property to look up cached values.