From a818ce0c193e933acd83ce2c9326f270e48c8276 Mon Sep 17 00:00:00 2001 From: James Lucas Date: Sat, 17 Jul 2021 14:15:50 +1000 Subject: [PATCH] Revert showDropDown back to the previous inverted state. showDropDown is apparently incorrect documentation, it works as hideDropDrop if true. --- src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php | 3 ++- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php index 3e9c8787..7053a5a5 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php @@ -35,7 +35,8 @@ class DataValidations $docValidation->setErrorStyle((string) $dataValidation['errorStyle']); $docValidation->setOperator((string) $dataValidation['operator']); $docValidation->setAllowBlank(filter_var($dataValidation['allowBlank'], FILTER_VALIDATE_BOOLEAN)); - $docValidation->setShowDropDown(filter_var($dataValidation['showDropDown'], FILTER_VALIDATE_BOOLEAN)); + // showDropDown is inverted (works as hideDropDown if true) + $docValidation->setShowDropDown(!filter_var($dataValidation['showDropDown'], FILTER_VALIDATE_BOOLEAN)); $docValidation->setShowInputMessage(filter_var($dataValidation['showInputMessage'], FILTER_VALIDATE_BOOLEAN)); $docValidation->setShowErrorMessage(filter_var($dataValidation['showErrorMessage'], FILTER_VALIDATE_BOOLEAN)); $docValidation->setErrorTitle((string) $dataValidation['errorTitle']); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index ec6cd8cb..58e6c064 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -699,7 +699,8 @@ class Worksheet extends WriterPart } $objWriter->writeAttribute('allowBlank', ($dv->getAllowBlank() ? '1' : '0')); - $objWriter->writeAttribute('showDropDown', ($dv->getShowDropDown() ? '1' : '0')); + // showDropDown is really hideDropDown Excel renders as true = hide, false = show + $objWriter->writeAttribute('showDropDown', (!$dv->getShowDropDown() ? '1' : '0')); $objWriter->writeAttribute('showInputMessage', ($dv->getShowInputMessage() ? '1' : '0')); $objWriter->writeAttribute('showErrorMessage', ($dv->getShowErrorMessage() ? '1' : '0'));