Handle the case of an invalid formula by defaulting to ptgInt + 0, which will avoid breaking the file

This commit is contained in:
MarkBaker 2022-03-13 10:53:07 +01:00
parent 83161de91e
commit a6e792082b
3 changed files with 9 additions and 9 deletions

View File

@ -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';

View File

@ -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;
}
}
}