Data validation float numbers

Topics: Developer Forum
Jul 20, 2012 at 7:04 PM

Hi, I'm using that:

$objValidation = $objPHPExcel->getActiveSheet()->getCell('D7')->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('Error');
$objValidation->setError('Digite una nota entre 0.0 y 5.0');
$objValidation->setPromptTitle('Nota permitida');
$objValidation->setPrompt('Solamente la nota entre 0.0 y 5.0 es permitida');
$objValidation->setFormula1(0);
$objValidation->setFormula2(5);

And work very well, but I need validate a number float, example, 0.0 and 5.0, I tested the follow:

$objValidation->setFormula1(0.0);
$objValidation->setFormula2(5.0);

And the follow:

$objValidation->setFormula1(0,0);
$objValidation->setFormula2(5,0);

But that dont work, ¿can you help me please?.

Jul 20, 2012 at 7:27 PM

Ok, is ready, I change de second linde for the follow:

$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_DECIMAL );

And now that its working, but if the cell is empty the validation dont work... Can´t you help me.