Can I -> Dropdown List OR Type Anything?

Topics: User Forum
Nov 9, 2011 at 4:20 PM

I'm trying to make a cell take a drop down list from a Named Range but if the user wants to just type something that isn't in the list they can, or they can leave it blank.

The dropdown is for their convenience, not for validation.

Can I do that with PHPExcel?

Nov 9, 2011 at 5:55 PM

Well, it turns out that I can.

    $objValidation = $excel->getActiveSheet()->getCell("A2")->getDataValidation();
    $objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST );
    $objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION );

I just setAllowBlank to true, made the validation style STYLE_INFORMATION and set the messages to false.
I'm not sure exactly which properties permitted it, I'm guessing STYLE_INFORMATION but I can select from the drop down or just type in whatever I want or leave it blank.