Created
November 21, 2013 18:25
-
-
Save rotexdegba/7586827 to your computer and use it in GitHub Desktop.
How to add drop down list to a cell in PHPExcel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$objValidation = $objPHPExcel->getActiveSheet()->getCell("C$curr_row")->getDataValidation(); | |
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST ); | |
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION ); | |
$objValidation->setAllowBlank(false); | |
$objValidation->setShowInputMessage(true); | |
$objValidation->setShowErrorMessage(true); | |
$objValidation->setShowDropDown(true); | |
$objValidation->setErrorTitle('Input error'); | |
$objValidation->setError('Value is not in list.'); | |
$objValidation->setPromptTitle('Pick from list'); | |
$objValidation->setPrompt('Please pick a value from the drop-down list.'); | |
$objValidation->setFormula1('"Item A,Item B,Item C"'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am generating template excel files and some columns should have a pre-filled list with posiible values. Super that it is possible!
But I only generate the header row (row 1) and when someone else wants to fill the data-rows (row 2 and above) the dropdown should appear. Is it possible to define a dropdown for unlimited rows in a certain column, without specifying an end row number?