This project has moved and is read-only. For the latest updates, please go here.

How to determine if cell has formula applied in it.

Feb 8, 2012 at 11:35 PM

I am reading an Excel file as a data source.  As I go through row by row, I check a certain cell for a value.  Sometimes the cell will only contain a number only.  Other times it will have a number that is a result of a formula (usually a sum...e.g. =SUM(F21:F22)).  

Is there a way for me to determine when I am at the particular cell, that even though it contains a number, that underlying that number is a formula??  I need to be able to do this so I can exclude these values when I come across them.

Any C# syntax you can provide is certainly appreciated.


Feb 8, 2012 at 11:43 PM

This seems to be working!

cellCheck = sheet.Cells[currentRow, currentCol].Formula.ToString();