diff --git a/samples/ConditionalFormatting/07_Expression_Comparisons.php b/samples/ConditionalFormatting/07_Expression_Comparisons.php index 43d6fe56..0f2b1a84 100644 --- a/samples/ConditionalFormatting/07_Expression_Comparisons.php +++ b/samples/ConditionalFormatting/07_Expression_Comparisons.php @@ -102,9 +102,9 @@ $expressionWizard->expression('ISEVEN(A1)') ->setStyle($yellowStyle); $conditionalStyles[] = $expressionWizard->getConditional(); -//$spreadsheet->getActiveSheet() -// ->getStyle($expressionWizard->getCellRange()) -// ->setConditionalStyles($conditionalStyles); +$spreadsheet->getActiveSheet() + ->getStyle($expressionWizard->getCellRange()) + ->setConditionalStyles($conditionalStyles); // Set rules for Sales Grid Row match against Country Comparison $cellRange = 'A17:D22'; diff --git a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php index f408692a..0f78b8c5 100644 --- a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php +++ b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php @@ -55,11 +55,11 @@ class ConditionalHelper $formula = Wizard\WizardAbstract::reverseAdjustCellRef((string) $condition, $cellRange); $this->parser->parse($formula); $this->tokens = $this->parser->toReversePolish(); - $this->size = strlen($this->tokens); + $this->size = strlen($this->tokens ?? ''); } catch (PhpSpreadsheetException $e) { - var_dump("PARSER EXCEPTION: {$e->getMessage()}"); - $this->tokens = null; - $this->size = 0; + // In the event of a parser error with a formula value, we set the expression to ptgInt + 0 + $this->tokens = pack('Cv', 0x1E, 0); + $this->size = 3; } } } diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index b77719bd..16059e28 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -2787,8 +2787,8 @@ class Worksheet extends BIFFwriter string $cellRange ): void { $record = 0x01B1; // Record identifier - $type = null; // Type of the CF - $operatorType = null; // Comparison operator + $type = null; // Type of the CF + $operatorType = null; // Comparison operator if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION) { $type = 0x02;