Call to a member function getBlipType() on a non-object

Topics: User Forum
Nov 29, 2012 at 5:55 AM
Edited Nov 29, 2012 at 5:58 AM

Hi!

I try to parse PNG from Excel sheet. The Excel file has one list (01_Body_Graph_Daily) and going to PHP-script from Microsoft SQL Reporting Services by e-mail and/or SMB-share, in any case, the error is the same:

PHP Fatal error:  Call to a member function getBlipType() on a non-object in /var/www/mail-edge.mil.zs/Classes/PHPExcel/Reader/Excel5.php on line 995

PHP code:

 

function getBodyImages($dataDir, $parseFile, $reporting_type)
{
    try {
        $objPHPExcel = PHPExcel_IOFactory::load($dataDir . $reporting_type . '/' . $parseFile);
    } catch (Exception $e) {
        die('Error loading file: ' . $e->getMessage());
    }
    $worksheet = $objPHPExcel->getActiveSheet();
    foreach ($worksheet->getDrawingCollection() as $i => $drawing) {
        if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
            ob_start();
            call_user_func(
                $drawing->getRenderingFunction(),
                $drawing->getImageResource()
            );
            $imageContents = ob_get_contents();
            ob_end_clean();

            $myFileName = $dataDir . $reporting_type . '/graph_' . ++$i . '.png';
            $trueFileName = 'graph_' . $i . '.png';
            file_put_contents($myFileName, $imageContents);
            $files[] = $trueFileName;
        }
    }
    return $files;
}

 

Ok, I download file from server to my Mac, opened it in MS Office 2011 for Mac, just save it (Cmd+S) and upload to server again, then run script - and voila - all drawings parsed successfuly.

 

Sometimes, this error is not appears, but script going to the infinite loop of Notices on this lines:

 

    try {
        $objPHPExcel = PHPExcel_IOFactory::load($dataDir . $reporting_type . '/' . $parseFile);
    } catch (Exception $e) {
        die('Error loading file: ' . $e->getMessage());
    }
   

 

I cannot post Notices now, but when it appear again I'll do it.

So - the question - where is the problem?

Two files (broken.xls and okay.xls) in attch.

Uh, and so strange - MacOS doesn't render preview in file icon for broken.xls and render for okay.xls (this file I saved in Excel by hands), screenshot in attch too.

Attch:

http://phpexcel.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=phpexcel&WorkItemId=10749&FileAttachmentId=6718

http://phpexcel.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=phpexcel&WorkItemId=10749&FileAttachmentId=6719

Thanx!

p.s. sorry for my english.