I use PHPExcel to create Excel template documents for users to download so that they can load bulk data.
As part of this, I want certain fields to be a selection from the drop-down list.
The DataValidation example shows how to do this for a single cell as follows:
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B5')->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"');
This is fine for a single cell, but I want all the cells in column B to be dropdowns when adding new rows of data. How can I achieve this?
thanks
source share