From bb0d413a677d9c35a4f8df1ff05a2f60e062712e Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 16 Aug 2012 00:29:07 +0100 Subject: [PATCH] Fix to dynamic autofilter expression in writer, preventing writing blanks="1" --- Classes/PHPExcel/Worksheet/AutoFilter.php | 4 ++++ Classes/PHPExcel/Writer/Excel2007/Worksheet.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Worksheet/AutoFilter.php b/Classes/PHPExcel/Worksheet/AutoFilter.php index f5a48cd9..e530a185 100644 --- a/Classes/PHPExcel/Worksheet/AutoFilter.php +++ b/Classes/PHPExcel/Worksheet/AutoFilter.php @@ -451,12 +451,16 @@ var_dump($ruleValue); ); break; case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER : + $ruleValues = array(); + $columnFilterTests[$columnID] = array( 'method' => '_filterTypeDynamicFilters', 'arguments' => $ruleValues ); break; case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER : + $ruleValues = array(); + $columnFilterTests[$columnID] = array( 'method' => '_filterTypeTopTenFilters', 'arguments' => $ruleValues diff --git a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index 770bff1b..eb0dfd26 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -765,7 +765,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ } foreach ($rules as $rule) { - if (($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && + if (($column->getFilterType() === PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER) && + ($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && ($rule->getValue() === '')) { // Filter rule for Blanks $objWriter->writeAttribute('blank', 1);