From c2b38b0ee02475867a44659bf6ac70e89270b115 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 12 Apr 2017 12:40:28 +0900 Subject: [PATCH] Error style of data validation was incorrectly written to Xls We use to write the wrong property to file, leading to a warning in PHP 7.1 since the `switch` never matched anything and the variable was left as a string instead of as an int. Closes https://github.com/PHPOffice/PHPExcel/issues/1110 --- src/PhpSpreadsheet/Cell/DataValidation.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index c7e7681d..7d710164 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -84,7 +84,7 @@ class DataValidation * * @var string */ - private $operator = ''; + private $operator = self::OPERATOR_BETWEEN; /** * Allow Blank. diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index e8b494a0..75d33633 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -2838,11 +2838,10 @@ class Worksheet extends BIFFwriter break; } - $type = (int) $type; $options |= $type << 0; // error style - $errorStyle = $dataValidation->getType(); + $errorStyle = $dataValidation->getErrorStyle(); switch ($errorStyle) { case \PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_STOP: $errorStyle = 0x00; @@ -2855,7 +2854,6 @@ class Worksheet extends BIFFwriter break; } - $errorStyle = (int) $errorStyle; $options |= $errorStyle << 4; // explicit formula? @@ -2904,7 +2902,6 @@ class Worksheet extends BIFFwriter break; } - $operator = (int) $operator; $options |= $operator << 20; $data = pack('V', $options);