I am trying to write a program to compare two excel files in C#. I am able to open the files n read the value of the excel but i would like to compare the text in the Cell.
For example In my sheet, If the Cell A3 is having a formula say "=A1+A2". I am able to retrieve the value using
((Range)worksheet.Cells[2,0]).Value
of A3(the total value of A1 and A2) but not "=A1+A2". How can i get the text.(.Text is always null)
Thanks you
Looks like the Formula property should have it.
"If the cell contains a constant, this property returns the constant. If the cell is empty, this Formula property returns an empty string. If the cell contains a formula, the Formula property returns the formula as a string in the same format that would be displayed in the formula bar (including the equal sign)."
((Range)worksheet.Cells[2,0]).Formula;
try
((Range)worksheet.Cells[2,0]).Formula
MSDN reference see http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.formula.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.