simple validation help need please, thanks!!!

Topics: Developer Forum, User Forum
Jul 5, 2010 at 10:04 AM

Hello everyone,

I am new to phpexcel, actually I am new to excel... I just found this lib and I think it is very good, but I do have 2 very simple questions about how to put validation in it:


1.  Required filed validation, I thought I just need to simply set 'AllowBlank' to false then done but it wasn't working:

$objValidation = $objPHPExcel->getActiveSheet()->getCell('B3')->getDataValidation();
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );
$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );
$objValidation->setErrorTitle('Input error');
$objValidation->setError('Required field!');
$objValidation->setPromptTitle('Allowed input');
$objValidation->setPrompt('Required field!');


2. If I only want to allow user to input a single string to a cell from a allowed list, say I only let user to input letter 'A', 'B', or 'C', how do I do that? is it something I can do with function 'setFormula1'?


Thanks so much for reading my thread!

Warm regards,