title: failed to delete buffer. No buffer to delete
body: <p>I am trying to generate an excel file with the extension .xlsx from the code below. I am able to download the file very well but when I open it with excel sheet, I receive the following warning error .. Excel cannot open the file 'dindi.xlsx' because the file format or file extension is not valid. Ensure that the file is not corrupted and that the file extension matches the format of the file.
  When I opened it with notepad ,the file had the following error:</p>
  
  <blockquote>
    <p>Notice:  ob_end_clean() [ref.outcontrol]: failed to delete buffer. No buffer to delete</p></p>
  </blockquote>
  
  <p>Below is the codeof what I'm trying to do.</p>
  
  <pre><code>public function exportResults() {
  
          $this -&gt; load -&gt; database();
          $query = $this -&gt; db -&gt; query("
          SELECT * FROM farm LIMIT 10");
          $results = $query -&gt; result_array();
          $objPHPExcel = new Excel();
  
  
  
  
  
          $objReader = PHPExcel_IOFactory::createReader('Excel2007');
          $objPHPExcel = $objReader-&gt;load('./files/farmdetails.xlsx');
  
  
          $objPHPExcel -&gt;getActiveSheet()-&gt;setTitle('farmreport');
  
          $objPHPExcel -&gt; setActiveSheetIndex(0);
          $i = 1;
          foreach ($results as $result) {
  
              $objPHPExcel -&gt; getActiveSheet() -&gt; SetCellValue('A' . $i, $result["name"]);
              $objPHPExcel -&gt; getActiveSheet() -&gt; SetCellValue('B' . $i, $result["dateofcontract"]);
              $objPHPExcel -&gt; getActiveSheet() -&gt; SetCellValue('C' . $i, $result["leasorname"]);
              $objPHPExcel -&gt; getActiveSheet() -&gt; SetCellValue('D' . $i, $result["acre"]);
              $objPHPExcel -&gt; getActiveSheet() -&gt; SetCellValue('E' . $i, $result["zone"]);
  
              $i++;
              echo $result["name"];
              }
  
  
  
          ob_end_clean();
          $filename = "dindi.xlsx";
          header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
          header("Cache-Control: no-store, no-cache, must-revalidate");
          header("Cache-Control: post-check=0, pre-check=0", false);
          header("Pragma: no-cache");
          header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
          header('Content-Disposition: attachment;filename=' . $filename);
  
          $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  
          ob_end_clean();
  
          $objWriter -&gt; save('php://output');
  
          $objPHPExcel -&gt; disconnectWorksheets();
          unset($objPHPExcel);
  
  
  
      }
  </code></pre>