diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 23f5ffef..f4073a5f 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -547,7 +547,7 @@ class ReferenceHelper $autoFilterRange = $autoFilter->getRange(); if (!empty($autoFilterRange)) { if ($pNumCols != 0) { - $autoFilterColumns = array_keys($autoFilter->getColumns()); + $autoFilterColumns = $autoFilter->getColumns(); if (count($autoFilterColumns) > 0) { sscanf($pBefore, '%[A-Z]%d', $column, $row); $columnIndex = Cell::columnIndexFromString($column); @@ -559,7 +559,7 @@ class ReferenceHelper $deleteColumn = $columnIndex + $pNumCols - 1; $deleteCount = abs($pNumCols); for ($i = 1; $i <= $deleteCount; ++$i) { - if (in_array(Cell::stringFromColumnIndex($deleteColumn), $autoFilterColumns)) { + if (isset($autoFilterColumns[Cell::stringFromColumnIndex($deleteColumn)])) { $autoFilter->clearColumn(Cell::stringFromColumnIndex($deleteColumn)); } ++$deleteColumn; diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 333fc540..7b050290 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -518,8 +518,10 @@ class Worksheet extends BIFFwriter foreach ($conditionalStyles as $conditional) { if ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION || $conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) { - if (!in_array($conditional->getHashCode(), $arrConditional)) { - $arrConditional[] = $conditional->getHashCode(); + if (!isset($arrConditional[$conditional->getHashCode()])) { + // This hash code has been handled + $arrConditional[$conditional->getHashCode()] = true; + // Write CFRULE record $this->writeCFRule($conditional); }