title: PHPExcel - Fatal error: Uncaught exception 'Exception' with message
body: <p>I am getting an error everytime I try to export an excel spreadsheet. The error is as follows:</p>
  
  <pre><code>Fatal error: Uncaught exception 'Exception' with message 'Worksheet!J6 -&gt; Worksheet!J6 -&gt; Cyclic Reference in Formula' in /classes/PHPExcel/Cell.php:293 Stack trace: 
      #0 /classes/PHPExcel/Writer/Excel2007/Worksheet.php(997): PHPExcel_Cell-&gt;getCalculatedValue() 
      #1 /classes/PHPExcel/Writer/Excel2007/Worksheet.php(943): PHPExcel_Writer_Excel2007_Worksheet-&gt;_writeCell(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_Worksheet), 'J6', Array, Array) 
      #2 /classes/PHPExcel/Writer/Excel2007/Worksheet.php(83): PHPExcel_Writer_Excel2007_Worksheet-&gt;_writeSheetData(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_Worksheet), Array) 
      #3 /classes/PHPExcel/Writer/Excel2007.php(282): PHPExcel_Writer_Excel2007_Worksheet-&gt;writeWorksheet(Object(PHPExcel_Worksheet), Array, false) 
      #4 /includes/reports_funcs.php(620): PHPExcel_Writer_Excel2007-&gt;save('reports/risk-bo...') #5 /createXlsxReport. in /classes/PHPExcel/Cell.php on line 293
  </code></pre>
  
  <p>I tried to look for a solution but so far no luck. I found another <a href="https://stackoverflow.com/questions/13786887/phpexcel-error-cyclic-reference-in-formula">stackoverflow</a> question which suggested adding <code>$objWriter-&gt;setPreCalculateFormulas(FALSE);</code> before the file save, but this gives me an empty spreadsheet.</p>
  
  <p>It has only started happening recently so I am really confused as to why this is happening. Any help would be greatly appreciated, cheers</p>
  
  <p>SAMPLE CODE - EDIT</p>
  
  <pre><code>$objPHPExcel-&gt;getActiveSheet(0)
      -&gt;setCellValueByColumnAndRow(0, $row, $pol_ref . 'e' . $end_numb)
      -&gt;setCellValueByColumnAndRow(1, $row, $insured_name)
      -&gt;setCellValueByColumnAndRow(2, $row, $vessel_name)
      -&gt;setCellValueByColumnAndRow(3, $row, $insurance_type . ' - ' . $end_type)
      -&gt;setCellValueByColumnAndRow(4, $row, $insured_domicile)
      -&gt;setCellValueByColumnAndRow(5, $row, gmdate("d-m-Y",$date_logged))
      -&gt;setCellValueByColumnAndRow(6, $row, $inception_date)
      -&gt;setCellValueByColumnAndRow(7, $row, $expiry_date)
      -&gt;setCellValueByColumnAndRow(8, $row, ($policy_limit == 0.00?$loh_limit:$policy_limit))
      -&gt;setCellValueByColumnAndRow(9, $row, $premium)
      -&gt;setCellValueByColumnAndRow(10, $row, "=sum(J".($row)."*".($seacurus_percent/100).")")
      -&gt;setCellValueByColumnAndRow(11, $row, "=sum(J".($row)."*".($placing_percent/100).")")
      -&gt;setCellValueByColumnAndRow(12, $row, "=sum(J".($row)."*".($rebate_percent/100).")")
      -&gt;setCellValueByColumnAndRow(13, $row, "=sum(J".($row)."*".($iptpercent/100).")")
      -&gt;setCellValueByColumnAndRow(14, $row, "=sum(".($binder_id==6?"(J".$row." - (P".$row."+L".$row."+O".$row."+P".$row."))":"J".($row))."*".$bgn_percent.")")
      -&gt;setCellValueByColumnAndRow(15, $row, "=sum(J".($row)."*".$ghc_percent.")")
      -&gt;setCellValueByColumnAndRow(16, $row, "=sum(J".($row)."*".($commission_percentage_sum/100).")");
  $row++;
  </code></pre>