From 6aae7649203a680e798c4b44a2bf1333920d5418 Mon Sep 17 00:00:00 2001 From: Mewes Kochheim Date: Sun, 28 May 2017 22:20:14 +0200 Subject: [PATCH] Use default values when writing validation in Xls Fixes the PHP 7.1 bug reported over at PHPOffice/PHPExcel#1110 The behavior should not change since the default value used should behave the same way as the string value in earlier PHP versions. Fixes a return type in the doc block of IReader. Closes #165 --- src/PhpSpreadsheet/Reader/IReader.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index 3d4bfa99..7ef8d48b 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -42,7 +42,7 @@ interface IReader * * @throws Exception * - * @return Spreadsheet + * @return \PhpOffice\PhpSpreadsheet\Spreadsheet */ public function load($pFilename); } diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 3e02af33..939b0f50 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -2791,6 +2791,8 @@ class Worksheet extends BIFFwriter /** * Store the DATAVALIDATIONS and DATAVALIDATION records. + * + * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ private function writeDataValidity() { @@ -2823,8 +2825,8 @@ class Worksheet extends BIFFwriter $options = 0x00000000; // data type - $type = $dataValidation->getType(); - switch ($type) { + $type = 0x00; + switch ($dataValidation->getType()) { case DataValidation::TYPE_NONE: $type = 0x00; break; @@ -2854,8 +2856,8 @@ class Worksheet extends BIFFwriter $options |= $type << 0; // error style - $errorStyle = $dataValidation->getErrorStyle(); - switch ($errorStyle) { + $errorStyle = 0x00; + switch ($dataValidation->getErrorStyle()) { case DataValidation::STYLE_STOP: $errorStyle = 0x00; break; @@ -2887,8 +2889,8 @@ class Worksheet extends BIFFwriter $options |= $dataValidation->getShowErrorMessage() << 19; // condition operator - $operator = $dataValidation->getOperator(); - switch ($operator) { + $operator = 0x00; + switch ($dataValidation->getOperator()) { case DataValidation::OPERATOR_BETWEEN: $operator = 0x00; break;