删除phpexel中的缓存或任何其他选项

时间:2017-01-02 09:56:14

标签: php phpexcel

下载文件时出现以下错误。

<b>Fatal error</b>:  Allowed memory size of 134217728 bytes exhausted (tried 
to allocate 24 bytes) in     <b>C:\xampp\htdocs\dailyquestion\admin\PHPEXCEL\Classes\PHPExcel\CachedObjectStora
ge\CacheBase.php</b> on line <b>173</b><br />

我想我应该在下载之前先删除缓存..或者你有其他选择请告诉我

UPDATE ...这是我的代码。我用它来下载.xls文件...如果你发现任何漏洞请告诉我       

  // $query = "SELECT m.id ,m.employee_id,m.name,count(m.id),m.branch,b.branchname,m.department,m.designation
  //  FROM main as m INNER JOIN branch as b ON 
  // m.branch=b.branchcode where m.question = '0' group by m.employee_id,m.department";

   $query = "SELECT m.id ,m.employee_id,m.name,count(m.id),sum(question!='0'),sum(question='0'),sum(ans='true_ans'),sum(ans='false_ans'),
   m.branch,b.branchname,m.department,m.designation
   FROM main as m INNER JOIN branch as b ON 
   m.branch=b.branchcode  group by m.employee_id,m.department";




  if ($result = mysql_query($query) or die(mysql_error())) {

     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getActiveSheet()->setTitle('List of Candidates');

    $rowNumber = 1;
  $headings = array('id','empoyee_id','name','total','attemted','not attempted','true answer','false answer','branch','branchname','department','designation');
  $objPHPExcel->getActiveSheet()->fromArray(array($headings),NULL,'A'.$rowNumber);

  $rowNumber++;

  // Loop through the result set
  while ($row = mysql_fetch_row($result)) {
     $col = 'A';
     foreach($row as $cell) {
        $objPHPExcel->getActiveSheet()->setCellValue($col.$rowNumber,$cell);
        $col++;
     }
     $rowNumber++;
  }
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="daily_login_entry.analysis.xls"');
     header('Cache-Control: max-age=0');

     $objWriter->save('php://output');
     exit();
  }
  echo 'a problem has occurred... no data retrieved from the database';
  ?>

0 个答案:

没有答案