From a7cf8c63e20822fe58e2af89047dc3af7b6615d6 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sat, 23 Aug 2014 13:54:21 +0100 Subject: [PATCH] Bugfix: Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0 --- Classes/PHPExcel/CachedObjectStorage/DiscISAM.php | 4 ++-- Classes/PHPExcel/Reader/HTML.php | 11 ++++++----- changelog.txt | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php b/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php index c46cdd95..cb38d0de 100644 --- a/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php +++ b/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php @@ -122,8 +122,8 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage // Set current entry to the requested entry $this->_currentObjectID = $pCoord; - fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']); - $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz'])); + fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']); + $this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz'])); // Re-attach this as the cell's parent $this->_currentObject->attach($this); diff --git a/Classes/PHPExcel/Reader/HTML.php b/Classes/PHPExcel/Reader/HTML.php index ec074f5a..3a59bb16 100644 --- a/Classes/PHPExcel/Reader/HTML.php +++ b/Classes/PHPExcel/Reader/HTML.php @@ -424,9 +424,13 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_ // Create a new DOM object $dom = new DOMDocument; // Reload the HTML file into the DOM object - $loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions()); + if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + $loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions()); + } else { + $loaded = $dom->loadHTMLFile($pFilename); + } if ($loaded === FALSE) { - throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document'); + throw new PHPExcel_Reader_Exception('Failed to load '. $pFilename. ' as a DOM Document'); } // Discard white space @@ -438,9 +442,6 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_ $content = ''; $this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content); -// echo '
'; -// var_dump($this->_dataArray); - // Return return $objPHPExcel; } diff --git a/changelog.txt b/changelog.txt index c20cf879..13f434e4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -30,6 +30,7 @@ Planned for v1.8.1 - Bugfix: (MBaker) Work Item GH-350 - Keep/set the value on Reader _loadSheetsOnly as NULL, courtesy of Restless-ET - Bugfix: (MBaker) Work Item CP18105 - Loading an Excel 2007 spreadsheet throws an "Autofilter must be set on a range of cells" exception - Bugfix: (MBaker) - Fix to autoloader registration for backward compatibility with PHP 5.2.0 not accepting the prepend flag +- Bugfix: (MBaker) Work Item GH-384 - DOM loadHTMLFile() failing with options flags when using PHP < 5.4.0 - General: (MBaker) - Small performance improvement for autosize columns - General: (frost-nzcr4) Work Item GH-379 - Change the getter/setter for zeroHeight to camel case - Feature: (WiktrzGE) Work Item GH-404 - Methods to manage most of the existing options for Chart Axis, Major Grid-lines and Minor Grid-lines