Bonjour à tous,
Je génère un fichier sur Excel2010 à l'aide de la librairie PHPExcel qui contient des données issues de ma BD MySQL.
Je cherche à contrôler au maximum les données qui pourront y être saisie (protection de certaines cellules, listes déroulantes...). Le but étant de pouvoir réimporté ce fichier dans ma base après modifications.
Je rencontre un problème avec les listes déroulantes. J'ai le code suivant :
ou ma variable $listeligne est une liste issue d'une requête sur ma base.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <?php $sheet->getStyle('A'.$i)->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); $objValidation = $objPHPExcel->getActiveSheet()->getCell('A'.$i)->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 de saisie'); $objValidation->setError('La valeur n\'est pas dans la liste'); $objValidation->setPromptTitle('Sélection'); $objValidation->setPrompt('Sélectionnez une valeur dans la liste'); $objValidation->setFormula1('"'. $listeligne .'"'); ?>
Lorsque ma liste est trop longue, le fichier n'est pas chargé et en effet en consultant la notice je suis tombé sur :
It is important to remember that any string participating in an Excel formula is allowed to be maximum 255 characters (not bytes). This sets a limit on how many items you can have in the string "Item A,Item B,Item C". Therefore it is normally a better idea to type the item values directly in some cell range, say A1:A3, and instead use, say, $objValidation->setFormula1('Sheet!$A$1:$A$3');. Another benefit is that the item values themselves can contain the comma ‘,’ character itself.
Je cherche donc à savoir s'il est possible de modifier ce maximum de 255 caractères et à quel endroit.
Cordialement,
E/ Si quelqu'un avait la gentillesse d'éditer ma balise code... je ne m'en sors pas
Partager