title: Get formula from Excel cell with python xlrd
body: <p>I have to <strong>port an algorithm from an Excel sheet to python code</strong> but I have to <strong>reverse engineer the algorithm from the Excel file</strong>.</p>
  
  <p>The Excel sheet is quite complicated, it contains many cells in which there are formulas that refer to other cells (that can also contains a formula or a constant).</p>
  
  <p>My idea is to analyze with a python script the sheet building a sort of table of dependencies between cells, that is:</p>
  
  <blockquote>
    <p>A1 depends on B4,C5,E7 formula: "=sqrt(B4)+C5*E7"<br>
    A2 depends on B5,C6    formula: "=sin(B5)*C6"<br>
    ...</p>
  </blockquote>
  
  <p>The <a href="http://pypi.python.org/pypi/xlrd" rel="noreferrer">xlrd</a> python module allows to read an XLS workbook but at the moment I can access to the <strong>value</strong> of a cell, not the <strong>formula</strong>.</p>
  
  <p>For example, with the following code I can get simply the value of a cell:</p>
  
  <pre><code>import xlrd
  
  #open the .xls file
  xlsname="test.xls"
  book = xlrd.open_workbook(xlsname)
  
  #build a dictionary of the names-&gt;sheets of the book
  sd={}
  for s in book.sheets():
      sd[s.name]=s
  
  #obtain Sheet "Foglio 1" from sheet names dictionary
  sheet=sd["Foglio 1"]
  
  #print value of the cell J141
  print sheet.cell(142,9)
  </code></pre>
  
  <p>Anyway, It seems to have no way to get the formul from the Cell object returned by the <em>.cell(...)</em> method.
  In <a href="https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html" rel="noreferrer">documentation</a> they say that it is possible to get a string version of the formula (in english because there is no information about function name translation stored in the Excel file). They speak about formulas (expressions) in the <em>Name</em> and <em>Operand</em> classes, anyway I cannot understand how to get the instances of these classes by the <em>Cell</em> class instance that must contains them.</p>
  
  <p>Could you suggest a code snippet that gets the formula text from a cell?</p>