Quantcast
Channel: PHPExcel Forum Rss Feed
Viewing all articles
Browse latest Browse all 2707

New Post: Adding default dropdown validation options to specific column

$
0
0
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

Viewing all articles
Browse latest Browse all 2707

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>