validation problem : still allowing invalid value when you click button "Ok" on the prompt message

Topics: Developer Forum
Jul 13, 2012 at 7:34 AM

Hello All

Here's my problem, I have a validation in one of my excel with the following code

    $objValidation = $sheet->getCell('G17' )->getDataValidation();
    $objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_DECIMAL );
    $objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION );
    $objValidation->setOperator( PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL);
    $objValidation->setAllowBlank(true);
    $objValidation->setShowInputMessage(true);
    $objValidation->setShowErrorMessage(true);
    $objValidation->setErrorTitle('Input error');
    $objValidation->setError('Only numeric entries are allowed.');
    $objValidation->setFormula1(0);
    $objValidation->setPromptTitle('Allowed input');
    $objValidation->setPrompt('Only numeric entries are allowed.');

When the user try to enter alphabet characters on 'G17' cell, the user then was prompted by the error message with the following buttons : "OK", "Cancel" , "Help" . 

When the user clicks the "OK" button, the alphabet entry was still accepted.

Is it possible to clear the cellvalue if there is an error in validation or highlight the cell values when there is an error in validation?

Thank you.

 

 

 

 

 

Jul 13, 2012 at 7:50 AM

i think i just need to change the error style into this

 

$objValidation->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );

 

 

Thanks all

Coordinator
Jul 13, 2012 at 4:54 PM

Glad to see you've already found your answer