mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-26 23:36:03 +03:00
Improve cloning of worksheet to handle autoFilter area cleanly
This commit is contained in:
parent
dbe64c5044
commit
2f4620c3f9
@ -2777,6 +2777,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
} elseif ($key == '_drawingCollection') {
|
||||
$newCollection = clone $this->_drawingCollection;
|
||||
$this->_drawingCollection = $newCollection;
|
||||
} elseif (($key == '_autoFilter') && (is_a($this->_autoFilter,'PHPExcel_Worksheet_AutoFilter'))) {
|
||||
$newAutoFilter = clone $this->_autoFilter;
|
||||
$this->_autoFilter = $newAutoFilter;
|
||||
$this->_autoFilter->setParent($this);
|
||||
} else {
|
||||
$this->{$key} = unserialize(serialize($val));
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ class PHPExcel_Worksheet_AutoFilter
|
||||
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
|
||||
|
||||
// The heading row should always be visible
|
||||
echo 'AutoFilter Heading Row ',$rangeStart[1],' is always SHOWN',PHP_EOL;
|
||||
// echo 'AutoFilter Heading Row ',$rangeStart[1],' is always SHOWN',PHP_EOL;
|
||||
$this->_workSheet->getRowDimension($rangeStart[1])->setVisible(TRUE);
|
||||
|
||||
$columnFilterTests = array();
|
||||
@ -763,17 +763,17 @@ class PHPExcel_Worksheet_AutoFilter
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Column Filter Test CRITERIA',PHP_EOL;
|
||||
var_dump($columnFilterTests);
|
||||
|
||||
// echo 'Column Filter Test CRITERIA',PHP_EOL;
|
||||
// var_dump($columnFilterTests);
|
||||
//
|
||||
// Execute the column tests for each row in the autoFilter range to determine show/hide,
|
||||
for ($row = $rangeStart[1]+1; $row <= $rangeEnd[1]; ++$row) {
|
||||
echo 'Testing Row = ',$row,PHP_EOL;
|
||||
// echo 'Testing Row = ',$row,PHP_EOL;
|
||||
$result = TRUE;
|
||||
foreach($columnFilterTests as $columnID => $columnFilterTest) {
|
||||
echo 'Testing cell ',$columnID.$row,PHP_EOL;
|
||||
// echo 'Testing cell ',$columnID.$row,PHP_EOL;
|
||||
$cellValue = $this->_workSheet->getCell($columnID.$row)->getCalculatedValue();
|
||||
echo 'Value is ',$cellValue,PHP_EOL;
|
||||
// echo 'Value is ',$cellValue,PHP_EOL;
|
||||
// Execute the filter test
|
||||
$result = $result &&
|
||||
call_user_func_array(
|
||||
@ -783,13 +783,13 @@ class PHPExcel_Worksheet_AutoFilter
|
||||
$columnFilterTest['arguments']
|
||||
)
|
||||
);
|
||||
echo (($result) ? 'VALID' : 'INVALID'),PHP_EOL;
|
||||
// echo (($result) ? 'VALID' : 'INVALID'),PHP_EOL;
|
||||
// If filter test has resulted in FALSE, exit the loop straightaway rather than running any more tests
|
||||
if (!$result)
|
||||
break;
|
||||
}
|
||||
// Set show/hide for the row based on the result of the autoFilter result
|
||||
echo (($result) ? 'SHOW' : 'HIDE'),PHP_EOL;
|
||||
// echo (($result) ? 'SHOW' : 'HIDE'),PHP_EOL;
|
||||
$this->_workSheet->getRowDimension($row)->setVisible($result);
|
||||
}
|
||||
|
||||
@ -815,7 +815,7 @@ class PHPExcel_Worksheet_AutoFilter
|
||||
$this->$key = array();
|
||||
foreach ($value as $k => $v) {
|
||||
$this->$key[$k] = clone $v;
|
||||
// attache the new cloned Column to this new cloned Autofilter object
|
||||
// attach the new cloned Column to this new cloned Autofilter object
|
||||
$this->$key[$k]->setParent($this);
|
||||
}
|
||||
} else {
|
||||
|
@ -369,6 +369,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
|
||||
$this->$key = array();
|
||||
foreach ($value as $k => $v) {
|
||||
$this->$key[$k] = clone $v;
|
||||
// attach the new cloned Rule to this new cloned Autofilter Cloned object
|
||||
$this->$key[$k]->setParent($this);
|
||||
}
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
|
Loading…
Reference in New Issue
Block a user