From 61bc7c8e98ad28ee49900866322e6e3f7edd5099 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 19 Aug 2012 11:14:34 +0100 Subject: [PATCH] Autofilter show/hide for all dynamic types now complete (still with debugs) --- Classes/PHPExcel/Worksheet/AutoFilter.php | 34 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Classes/PHPExcel/Worksheet/AutoFilter.php b/Classes/PHPExcel/Worksheet/AutoFilter.php index 3bfaa455..ee5b8cd8 100644 --- a/Classes/PHPExcel/Worksheet/AutoFilter.php +++ b/Classes/PHPExcel/Worksheet/AutoFilter.php @@ -338,13 +338,27 @@ class PHPExcel_Worksheet_AutoFilter return $returnVal; } - private static function _filterTypeDynamicFilters($cellValue,$testSet) + private static function _filterTestInPeriodDateSet($cellValue,$testSet) { - echo 'CALLING _filterTypeDynamicFilters',PHP_EOL; + echo 'CALLING _filterTestInPeriodDateSet',PHP_EOL; - return TRUE; + if (($cellValue == '') || ($cellValue === NULL)) { + echo 'EMPTY CELL',PHP_EOL; + return FALSE; + } + + if (is_numeric($cellValue)) { + $dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue)); + if (in_array($dateValue,$testSet)) { + return TRUE; + } + } + + return FALSE; } + + private static function _filterTypeTopTenFilters($cellValue,$testSet) { echo 'CALLING _filterTypeTopTenFilters',PHP_EOL; @@ -598,6 +612,20 @@ class PHPExcel_Worksheet_AutoFilter // Date based if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') { // Month or Quarter + list($periodType,$period) = sscanf($dynamicRuleType,'%[A-Z]%d'); + if ($periodType == 'M') { + $ruleValues = array($period); + } else { + --$period; + $periodEnd = (1+$period)*3; + $periodStart = 1+$period*3; + $ruleValues = range($periodStart,periodEnd); + } + $columnFilterTests[$columnID] = array( + 'method' => '_filterTestInPeriodDateSet', + 'arguments' => $ruleValues + ); + $filterColumn->setAttributes(array()); } else { // Date Range $columnFilterTests[$columnID] = $this->_dynamicFilterDateRange($dynamicRuleType, $filterColumn);