Problems PHPExcel - Excessive Overhead of memory

Topics: Developer Forum, Project Management Forum, User Forum
Mar 13, 2014 at 6:09 PM
Edited Mar 13, 2014 at 6:10 PM
Hello to everyone.
Would help to solve a problem I'm having.
Always used the PHPExcel class to export small reports.

This time I am trying to export a report of 234 rows and N (dynamic) columns in sheets N, where N ranges from 1 to 12 (months).

When testing with 2 sheets (1-2) slowly on average 8 seconds and exports, while trying with 6 sheets it exports the file with 0 bytes (empty)
Mar 13, 2014 at 6:14 PM
My Script
$periodo = $objRel->getPeriodo();
        foreach($periodo as $kp =>$p){
            if(is_numeric($kp)){
                $pX = strtoupper(gmstrftime("%h", strtotime($p)));
                $pP = substr($p, 0,7);
                $objWorkSheet = $objPHPExcel->createSheet($kp); 
                $objWorkSheet->setTitle($pX);
                $objWorkSheet->mergeCells('A3:B3');
                $objWorkSheet->freezePane('C4');
                $objWorkSheet->setCellValue("A3","Classif");

                $i = 4;
                foreach($arrMatrixClass as $k => $v){
                    $output = mb_convert_encoding($v,"UTF-8", "ISO-8859-1");
                    $objWorkSheet->setCellValue("A".$i,$k)
                                 ->setCellValue("B".$i,$output);
                    if(substr($k,2) != "00"){
        //                $this->SyncClassToObra($Sheet,$i,$Sheet->getTitle(),$k,"C");
                        $l = 'C';
                        //$p = $objWorkSheet->getTitle();
                        $arrObras = $objRel->getObras();
                        $this->tst[] = $arrObras;
                        foreach ($arrObras as $ObjObra){
                            $objWorkSheet->setCellValue($l."3",$ObjObra->getObraNum());
                            $arrCC = $ObjObra->getClassCusto();
                            if(isset($arrCC[$pP])){
                                $objWorkSheet->setCellValue($l.$i,$arrCC[$pP][$k]);
                            }
                            $l++;
                        }
                        //echo 'secs. Memory usage: ', round(((memory_get_usage(true) / 1024) / 1024), 2), 'Mb</br>';
                    }
                    $i++;
                }
            }
        }