PHP CLI crashing when processing XLS files but not on XLSX or CSV

Topics: Developer Forum
Jun 23, 2014 at 12:42 PM
Edited Jun 24, 2014 at 9:05 AM
  1. ADDING: Seems the script is making PHP crash, I ran the script thru the CLI and apparently CLI crashes so this points that PHP is failing on something. Is it possible that PHPExcel is doing something naughty when reading XLS?
  2. ADDING 2: Seems its something with the destructor in PHPExcel.php. If I comment out these two functions its no problem anymore. When I try a XLSX file, it runs smoothly, how come its only crashing when I do a XLS? The array is outputed correctly but CLI is giving up after that.
    //PHPExcel_Calculation::unsetInstance($this);
    //$this->disconnectWorksheets();
I get connection is reset when running a script that utilize PHPExcel for a XLS file. Same script is running fine with CSV or XLSX.

Setup:
Windows 7 64bit
Apache 2.2
PHP 5.2.6
PHPExcel 1.7.9

Nothing in PHP logs but Apache says:

[Mon Jun 23 14:37:00 2014] [notice] Parent: child process exited with status 255 -- Restarting.

Weird part is that its only a problem with the XLS files. Any advice?

Code:

File 1:

<?php
require ("class/ExcelFileReader.php");

$excelFileReader = new ExcelFileReader();
$excelFileReader->setFileName('kingdom/tspid/tspidn.xls');
try {
$result = $excelFileReader->getResultArray();
echo var_dump($result);
} catch (Exception $e) {
die($e->getMessage());
}

File 2 function that provides the array:
public function getResultArray() {
    if (file_exists($this->getFileName())) {
        $fileType = PHPExcel_IOFactory::identify($this->getFileName());
        if ($fileType == "CSV") {
            $objReader = PHPExcel_IOFactory::createReader($fileType);
            $objReader->setReadDataOnly(true);
            $objReader->setDelimiter($this->getDelimiter());
            $objReader->setEnclosure($this->getEnclosure());
            $objReader->setLineEnding($this->getLineBreak());
            $objReader->setInputEncoding($this->getEncoding());
            $objPHPExcel = $objReader->load($this->getFileName());
        } else {
            $objPHPExcel = PHPExcel_IOFactory::load($this->getFileName());
        }

        $sheetArray = array();
        $worksheet = $objPHPExcel->getActiveSheet();
        foreach ($worksheet->getRowIterator() as $row) {
            $cellIterator = $row->getCellIterator();
            $cellIterator->setIterateOnlyExistingCells(false);
            $rowArray = array();
            foreach ($cellIterator as $cell) {
                $rowArray[] = $cell->getValue();
            }
            $sheetArray[] = $rowArray;
        }
        //Set result
        $this->_result = $sheetArray;
        return $sheetArray;
    } else {
        throw new Exception("File do not exists!");
    }
}
If anyone has any suggestions or happends to see this error, give me a shout,

Best regards,

Gabriel
Jun 24, 2014 at 6:26 AM
Edited Jun 24, 2014 at 10:25 AM
Solved by downgrading to 1.7.8.
Marked as answer by gabrielpaulsson on 6/24/2014 at 3:25 AM