Adding default dropdown validation options to specific column

Apr 22, 2013 at 8:39 AM
Hi
I am trying to generate template Excel documents for users to download in order for them to upload bulk data.
As part of this, I want certain fields to be choices from a dropdown.

The DataValidation example shows how to do this for an individual 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"'); // Make sure to put the list items between " and " !!!

This is fine for an individual cell, but I want all cells in Column B to be dropdowns when new data rows are added. How can I achieve this?

Thanks
Pandy