I am trying to validate data for a range of cells in PHPExcel . Checking the operation of one cell.
$objValidation = $objPHPExcel->getActiveSheet()->getCell('A1')->getDataValidation(); $objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE ); $objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP ); $objValidation->setAllowBlank(true); $objValidation->setShowInputMessage(true); $objValidation->setShowErrorMessage(true); $objValidation->setErrorTitle('Input error'); $objValidation->setError('Number is not allowed!'); $objValidation->setPromptTitle('Allowed input'); $objValidation->setPrompt('Only 1 and 0 are allowed.'); $objValidation->setFormula1(0); $objValidation->setFormula2(1);
I can check other cells by creating such a clone.
$objPHPExcel->getActiveSheet()->getCell("A2")->setDataValidation(clone $objValidation);
But if I try to check the data through a loop, it freezes.
$j = 2; while($j <= 10) { $objPHPExcel->getActiveSheet()->getCell("A$j")->setDataValidation(clone $objValidation); }
What am I doing wrong here?
PS Looping works with other functions like getStyle() , etc.
source share