From d9fa784e1bffa1216c936d9102bdec1489ef7780 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sun, 27 Jul 2014 15:18:00 +0100 Subject: [PATCH] Bugfix: Work Item CP18105 - Loading an Excel 2007 spreadsheet throws an "Autofilter must be set on a range of cells" exception Fix to jpgraph path for Chart Rendering tests --- Classes/PHPExcel/Reader/Excel2007.php | 17 +++++++++++++++-- Examples/35chartrender.php | 2 +- changelog.txt | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Classes/PHPExcel/Reader/Excel2007.php b/Classes/PHPExcel/Reader/Excel2007.php index a5da6e12..d5c947ee 100644 --- a/Classes/PHPExcel/Reader/Excel2007.php +++ b/Classes/PHPExcel/Reader/Excel2007.php @@ -1007,7 +1007,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) { $autoFilter = $docSheet->getAutoFilter(); - $autoFilter->setRange((string) $xmlSheet->autoFilter["ref"]); + + $autoFilterRange = (string) $xmlSheet->autoFilter["ref"]; + if (strpos($autoFilterRange, ':') === false) { + $autoFilterRange = "${autoFilterRange}:${autoFilterRange}"; + } + $autoFilter->setRange($autoFilterRange); + foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) { $column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]); // Check for standard filters @@ -1575,7 +1581,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE case '_xlnm._FilterDatabase': if ((string)$definedName['hidden'] !== '1') { - $docSheet->getAutoFilter()->setRange($extractedRange); + $extractedRange = explode(',', $extractedRange); + foreach ($extractedRange as $range) { + $autoFilterRange = $range; + if (strpos($autoFilterRange, ':') === false) { + $autoFilterRange = "${autoFilterRange}:${autoFilterRange}"; + } + $docSheet->getAutoFilter()->setRange($autoFilterRange); + } } break; diff --git a/Examples/35chartrender.php b/Examples/35chartrender.php index 710cddb4..f0e79636 100644 --- a/Examples/35chartrender.php +++ b/Examples/35chartrender.php @@ -46,7 +46,7 @@ include 'PHPExcel/IOFactory.php'; // Change these values to select the Rendering library that you wish to use // and its directory location on your server $rendererName = PHPExcel_Settings::CHART_RENDERER_JPGRAPH; -$rendererLibrary = 'jpgraph3.5.0b1/src'; +$rendererLibrary = 'jpgraph3.5.0b1/src/'; $rendererLibraryPath = '/php/libraries/Charts/' . $rendererLibrary; diff --git a/changelog.txt b/changelog.txt index 51fc4a2c..2754f3c1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -28,6 +28,7 @@ Planned for v1.8.1 - Bugfix: (ymaerschalck) Work Item GH-405 - XML External Entity (XXE) Processing, different behaviour between simplexml_load_string() and simplexml_load_file(). - Bugfix: (MBaker) - Fix to ensure that current cell is maintained when executing formula calculations - 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 - 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