From b964788d5c55f9c08a2320579d33a809bfa6c1f2 Mon Sep 17 00:00:00 2001 From: "Herman M. Hofman" Date: Tue, 19 Jan 2016 12:15:10 +0100 Subject: [PATCH] FIX PHP Fatal Error on an invalid Blip Field. For (still) unknown reasons, PHPExcel detects a wrong field type. If there is no BSE Index, we will fail here and other fields are not read. So if the BSE Index < 1, continue with the next field. TODO: Why is there no BSE Index? Is this a new Office Version? Password protected field? More likely : a uncompatible picture PHP Notice: Undefined offset: -1 in Classes/PHPExcel/Reader/Excel5.php on line 1063 PHP Fatal error: Call to a member function getBlipType() on a non-object in Classes/PHPExcel/Reader/Excel5.php on line 1064 --- src/PhpSpreadsheet/Reader/Xls.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 11a62ff6..2f84ce9f 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1031,6 +1031,15 @@ class Xls extends BaseReader implements IReader // picture // get index to BSE entry (1-based) $BSEindex = $spContainer->getOPT(0x0104); + + // If there is no BSE Index, we will fail here and other fields are not read. + // Fix by checking here. + // TODO: Why is there no BSE Index? Is this a new Office Version? Password protected field? + // More likely : a uncompatible picture + if (!$BSEindex) { + continue; + } + $BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection(); $BSE = $BSECollection[$BSEindex - 1]; $blipType = $BSE->getBlipType();