title: PHPExcel : generating error due to php output?
body: <p>After building my spreadsheet using PHPExcel, I am unable to open the "save as" or "open" dialog. I got the following code snippet right from the examples directory that comes with the PHPExcel library.</p>
  
  <pre><code>header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Content-Disposition: attachment;filename="01simple.xlsx"');
  header('Cache-Control: max-age=0');
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  $objWriter-&gt;save('php://output');
  exit;
  </code></pre>
  
  <p>My JavaScript:</p>
  
  <pre><code>$(document).on('submit', '#myForm', function(e) {
          $.post('mail.php', $(this).serialize(), function (data) {
              $('.signature-field,.notes').hide();
              //SUCCESS
              $('.successORfail').html(data);
                  setTimeout(function(){
                      $(".successORfail").fadeOut("slow", function () {
                          $(".successORfail").empty().show();
                      });
                  }, 4500);
          }).error(function() {
              alert("Fatal Error: mail.php not found!");
          });
          e.preventDefault();
      });
  </code></pre>
  
  <p><strong>Note:</strong> the code above generates the alert message "Fatal Error: mail.php not found!" that I set up. Other than that, it does not generate any error messages, it does not save or create an excel file. </p>
  
  <p>When I use the following method, without any headers, the excel file is created perfectly, and saves on the server, without any errors:</p>
  
  <pre><code>    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
      $objWriter-&gt;save('MyExcel.xlsx');
  </code></pre>
  
  <p>I would truly appreciate any help with troubleshooting this error, as I have been working on this for a very long time now.</p>
  
  <p>Many thanks in advance!</p>