Issue
I try to build a dropdown list with PHPExcel (v1.7.9), but values with comma are not exported correctly
For example : if i want to export these two values : "12" and "5,9", the dropdown list I want is :
12
5,9
But i Obtain this :
12
5
9
And i found none answer on the web to this problem.
Have you an idea ?
$objValidation = $excel->getActiveSheet()->getCell($nextLetter . $beginLine)->getDataValidation();
$objValidation->setType(PHPExcel_Cell_DataValidation::TYPE_LIST);
$objValidation->setErrorStyle(PHPExcel_Cell_DataValidation::STYLE_INFORMATION);
$objValidation->setAllowBlank(false);
$objValidation->setShowInputMessage(true);
$objValidation->setShowErrorMessage(true);
$objValidation->setShowDropDown(true);
$objValidation->setErrorTitle('Erreur');
$objValidation->setError('Cette valeur n\'est pas dans la liste');
$objValidation->setPromptTitle('Sélectionner la valeur :');
$objValidation->setPrompt('Merci de choisir une valeur dans la liste :');
$objValidation->setFormula1(/*????*/);
Solution
One solution would be to have a series of cells containing the possible values, and set the formula to that range:
// Set cells containing our possible list values
$objValidation = $objPHPExcel->getActiveSheet()
->setCellValueExplicit('A1', "12");
$objValidation = $objPHPExcel->getActiveSheet()
->setCellValueExplicit('A2', "9,5");
// Set the data validation list
$objValidation = $objPHPExcel->getActiveSheet()
->getCell("B1")->getDataValidation();
$objValidation->setType(PHPExcel_Cell_DataValidation::TYPE_LIST);
$objValidation->setErrorStyle(PHPExcel_Cell_DataValidation::STYLE_INFORMATION);
$objValidation->setAllowBlank(false);
$objValidation->setShowInputMessage(true);
$objValidation->setShowErrorMessage(true);
$objValidation->setShowDropDown(true);
$objValidation->setErrorTitle('Erreur');
$objValidation->setError('Cette valeur n\'est pas dans la liste');
$objValidation->setPromptTitle('Sélectionner la valeur :');
$objValidation->setPrompt('Merci de choisir une valeur dans la liste :');
// Set the formula to the range of cells containing the list values
$objValidation->setFormula1('=A1:A2');
Another alternative would be to use a Unicode full width comma between 9 and 5 using U-FF0C
Answered By - Mark Baker Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.