title: How to read the displayed value of a spreadsheet cell, not the formula?
body: <p>I have a program that reads the value of a cell in a spreadsheet (via COM) by accessing its 'Text' member. When I was using Excel 2003, my program correctly returned the displayed value of the cell. Now I am using OpenOffice Calc, and instead I am getting back the formula in the cell ('=SUM(F8:F10)').</p>
  
  <p>To complicate matters, I am using a tool called <a href="http://sourceforge.net/projects/automateit/" rel="nofollow">AutomateIT!</a> to let me treat Calc as if it was Excel, so it might be that that's causing the problem instead of Calc.</p>
  
  <p>My program is in Python, and I use the win32com.client library to create the COM dispatcher. 
  This is the essence of the Python code (the 'empty' function always returns false for a cell containing a formula):</p>
  
  <pre><code>from win32com.client import Dispatch
  
  def empty(cell):
      """Returns false if the specified cell has a non-zero value in it"""
      val = sheet.Range(cell).Text
      return val == 0.0 or val == '' or val == None
  
  xlApp = Dispatch('Excel.Application')   # Actually opens OpenOffice Calc, thanks to AutomateIT!
  
  xlApp.Workbooks.Open('myfile.ods')
  
  sheet = xlApp.Workbooks(1).Sheets(1)
  
  if empty('F12'):
      sheet.Range('C2').Value = 'X'   # Never get here because F12 is a formula cell
  
  ...
  </code></pre>
  
  <p>Using 'Value' in empty() gives the same value as 'Text'.</p>