Help Memory

Nov 5, 2008 at 2:41 PM
I m trying to use and modify an example that exports a large document but i get           

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 648 bytes) in F:\phpexcel\Classes\PHPExcel\Cell\DataType.php on line

I m trying to create a xlsx with 5000 rows

        $objPHPExcel = new PHPExcel();
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->setUseDiskCaching(true);
        $objWriter->setOffice2003Compatibility(true);

.... some stuff to set active sheet and document property ....

for ($i = 2; $i <= 5000; $i++) {
    $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i");
    $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, "LName $i");
    $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, "PhoneNo $i");
    $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, "FaxNo $i");
    $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, true);
}

           
$objWriter->save( "php://output");

Is there a way to clean the used memory and  flush the sheet directly into the file before the save command?

I need to export a db into a file xlsx so no styles, formulas and so on.

thanks a lot for the support

bye
emag
Developer
Nov 5, 2008 at 5:43 PM
Exhausted memory; solve by raising memory limit; check this thread:
http://www.codeplex.com/PHPExcel/Thread/View.aspx?ThreadId=36847

Clean up memory; not easy, check out answer in this thread:
http://www.codeplex.com/PHPExcel/Thread/View.aspx?ThreadId=38176