Time limit error when reading Excel5 files.

Topics: Developer Forum, User Forum
Jun 14, 2011 at 9:19 PM

The specific error I receive is:

Fatal error: Maximum execution time of XX seconds exceeded in /PHPExcel/Shared/OLERead.php on line 114

The line number changes between 114 and 112. I've tried with a max execution time of 1000 seconds and it still has the problem.

The problem does not occur for Excel2007 files.

The code is as follows:

        ini_set("memory_limit", "256M");

        error_reporting(E_ALL);
        ini_set('display_errors', '1');
        
        foreach ($_FILES AS $fieldName => $sourceFile) {
            if (!empty($sourceFile["tmp_name"])) {

                $inputFile = $sourceFile["tmp_name"];

                $objPHPExcel = new PHPExcel();

                $objPHPExcel = PHPExcel_IOFactory::load($inputFile);

                header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                header('Content-Disposition: attachment;filename="ExcelTest' . date('ymd') . '.xlsx"');
                header('Cache-Control: max-age=0');


                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
                $objWriter->save('php://output');

                $objPHPExcelOutput->disconnectWorksheets();
                unset($objPHPExcelOutput);
                Yii::app()->end();
            }
        }

The server is Apache 2 with PHP 5.3.6. This issue is only occurring on one server so I imagine there must be a setting somewhere that needs to be changed, if anyone has any advice, it would be appreciated.

Jun 14, 2011 at 9:26 PM

I forgot to add my PHPExcel version: 1.7.3c

Jul 22, 2011 at 6:16 AM

try this...

 

 php.ini  set

magic_quotes_routine = Off

 

or before executing PHPExcel, add code as follow :

ini_set('magic_quotes_runtime', 'Off');

 

Jul 22, 2011 at 4:10 PM

or set your execution time with the help of set_time_limit(int sec)  sec number of seconds you think ur processes will take