|
62 | 62 | ->setCellValue('A3', "Number:") |
63 | 63 | ->setCellValue('B3', "10") |
64 | 64 | ->setCellValue('A5', "List:") |
65 | | - ->setCellValue('B5', "Item A"); |
| 65 | + ->setCellValue('B5', "Item A") |
| 66 | + ->setCellValue('A7', "List #2:") |
| 67 | + ->setCellValue('B7', "Item #2") |
| 68 | + ->setCellValue('D2', "Item #1") |
| 69 | + ->setCellValue('D3', "Item #2") |
| 70 | + ->setCellValue('D4', "Item #3") |
| 71 | + ->setCellValue('D5', "Item #4") |
| 72 | + ->setCellValue('D6', "Item #5") |
| 73 | + ; |
66 | 74 |
|
67 | 75 |
|
68 | 76 | // Set data validation |
|
91 | 99 | $objValidation->setError('Value is not in list.'); |
92 | 100 | $objValidation->setPromptTitle('Pick from list'); |
93 | 101 | $objValidation->setPrompt('Please pick a value from the drop-down list.'); |
94 | | -$objValidation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the list items between " and " !!! |
| 102 | +$objValidation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the list items between " and " if your list is simply a comma-separated list of values !!! |
| 103 | + |
| 104 | + |
| 105 | +$objValidation = $objPHPExcel->getActiveSheet()->getCell('B7')->getDataValidation(); |
| 106 | +$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST ); |
| 107 | +$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION ); |
| 108 | +$objValidation->setAllowBlank(false); |
| 109 | +$objValidation->setShowInputMessage(true); |
| 110 | +$objValidation->setShowErrorMessage(true); |
| 111 | +$objValidation->setShowDropDown(true); |
| 112 | +$objValidation->setErrorTitle('Input error'); |
| 113 | +$objValidation->setError('Value is not in list.'); |
| 114 | +$objValidation->setPromptTitle('Pick from list'); |
| 115 | +$objValidation->setPrompt('Please pick a value from the drop-down list.'); |
| 116 | +$objValidation->setFormula1('$D$2:$D$6'); // Make sure NOT to put a range of cells or a formula between " and " !!! |
95 | 117 |
|
96 | 118 |
|
97 | 119 | // Set active sheet index to the first sheet, so Excel opens this as the first sheet |
|
0 commit comments