title: Set Memory Limit and Time Limit in PHPExcel
body: <p>I have many arrays and i print it into excel using PHPExcel. Some times it need many column to write. It is over 5000 column.</p>
  
  <p>The problem is sometime even the column is over from 5000 column, it can be print succeesfully but sometime it show as corrupted file.</p>
  
  <p>I have read this : <a href="https://stackoverflow.com/questions/4895230/why-phpexcel-does-not-allow-to-write-more-than-5000-rows">Why PHPExcel does not allow to write more than 5000 rows</a></p>
  
  <p>But still im confusing.</p>
  
  <p>This is my code :</p>
  
  <pre><code> &lt;?php
  session_start();
  error_reporting(E_ALL);
  ini_set('display_errors', TRUE);
  ini_set('display_startup_errors', TRUE);
  date_default_timezone_set('Europe/London');
  
  if (PHP_SAPI == 'cli')
      die('This example should only be run from a Web Browser');
  
  /** Include PHPExcel */
  require_once 'PHPExcel.php';
  
  // Create new PHPExcel object
  $objPHPExcel = new PHPExcel();
  
  // Set document properties
  $objPHPExcel-&gt;getProperties()-&gt;setCreator("Valerian Timothy")
                               -&gt;setLastModifiedBy("Valerian Timothy")
                               -&gt;setTitle("Excel Document")
                               -&gt;setSubject("Data Mining")
                               -&gt;setDescription("Count how many words exists.")
                               -&gt;setKeywords("Data Mining")
                               -&gt;setCategory("Data Mining");
  
  
  // Add some data
  $objPHPExcel-&gt;setActiveSheetIndex(0)
              -&gt;setCellValue('A1', 'Username')
              -&gt;setCellValue('B1', 'Jumlah')
              -&gt;setCellValue('C1', 'Hashtag')
              -&gt;setCellValue('D1', 'Jumlah')
              -&gt;setCellValue('E1', 'Etc')
              -&gt;setCellValue('F1', 'Jumlah')
              -&gt;setCellValue('G1', 'Date')
              -&gt;setCellValue('H1', 'Jumlah');
  
  // Miscellaneous glyphs, UTF-8
  if($_SESSION['username'] != "")
  {
      $w = 2;
      foreach($_SESSION['username'] as $user =&gt; $jumlah)
      {
          $cellUser = 'A' . $w;
          $cellJumlah = 'B' . $w;
          $objPHPExcel-&gt;setActiveSheetIndex(0)
          -&gt;setCellValue($cellUser, $user)
          -&gt;setCellValue($cellJumlah, $jumlah);
          $w++;
      }
  }
  
  if($_SESSION['hashtag'] != "")
  {
      $x = 2;
      foreach($_SESSION['hashtag'] as $hashtag =&gt; $jumlah)
      {
          $cellUser = 'C' . $x;
          $cellJumlah = 'D' . $x;
          $objPHPExcel-&gt;setActiveSheetIndex(0)
          -&gt;setCellValue($cellUser, $hashtag)
          -&gt;setCellValue($cellJumlah, $jumlah);
          $x++;
      }
  }
  
  if($_SESSION['etc'] != "")
  {
      $y = 2;
      foreach($_SESSION['etc'] as $etc =&gt; $jumlah)
      {
          $cellUser = 'E' . $y;
          $cellJumlah = 'F' . $y;
          $objPHPExcel-&gt;setActiveSheetIndex(0)
          -&gt;setCellValue($cellUser, $etc)
          -&gt;setCellValue($cellJumlah, $jumlah);
          $y++;
      }
  }
  
  if(!empty($_SESSION['tanggal']))
  {
      $z = 2;
      foreach($_SESSION['tanggal'] as $date =&gt; $jumlah)
      {
          $cellUser = 'G' . $z;
          $cellJumlah = 'H' . $z;
          $objPHPExcel-&gt;setActiveSheetIndex(0)
          -&gt;setCellValue($cellUser, $date)
          -&gt;setCellValue($cellJumlah, $jumlah);
          $z++;
      }
  }
  
  foreach(range('A','H') as $columnID) {
      $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension($columnID)
          -&gt;setAutoSize(true);
  }
  // Rename worksheet
  $objPHPExcel-&gt;getActiveSheet()-&gt;setTitle('Simple');
  
  
  // Set active sheet index to the first sheet, so Excel opens this as the first sheet
  $objPHPExcel-&gt;setActiveSheetIndex(0);
  $today = strtotime(date('Y-m-d H:i:s'));
  
  // Redirect output to a client’s web browser (Excel2007)
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Content-Disposition: attachment;filename="Data-Mining'.$today.'.xlsx"');
  header('Cache-Control: max-age=0');
  // If you're serving to IE 9, then the following may be needed
  header('Cache-Control: max-age=1');
  
  // If you're serving to IE over SSL, then the following may be needed
  header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
  header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  header ('Pragma: public'); // HTTP/1.0
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  $objWriter-&gt;save('php://output');
  exit;
  session_destroy();
  ?&gt;
  </code></pre>
  
  <p>Could you help me to fix it ?</p>