How to create Dropdown list in excel using php

0 votes

I need to use PHP to construct a drop-down list in Excel. Actually, I need to limit user input to a predetermined value. check out the picture. I successfully generated an excel file, but I was unable to make a drop-down menu. Google was of no use:) Please look at this. image. Thanks in advance

enter image description here

Oct 3, 2022 in Others by Kithuzzz
• 38,000 points
3,418 views

1 answer to this question.

0 votes

Try this:

$objValidation = $objPHPExcel->getActiveSheet()->getCell('B'.$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('Input error');
$objValidation->setError('Value is not in list.');
$objValidation->setPromptTitle('Pick from list');
$objValidation->setPrompt('Please pick a value from the drop-down list.');
$objValidation->setFormula1('"Rate,Margin"');
answered Oct 3, 2022 by narikkadan
• 86,360 points

Related Questions In Others

0 votes
1 answer

How to create page borders using Apache POI in excel files with Java?

Microsoft Excel cannot do this. Libreoffice Calc ...READ MORE

answered Dec 13, 2022 in Others by narikkadan
• 86,360 points
1,678 views
0 votes
1 answer

How to create subnet inside a VPC in AWS using Terraform?

Hi@akhtar, You need to use aws_subnet resource inside your ...READ MORE

answered Jul 21, 2020 in Others by MD
• 95,460 points
1,183 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,580 points
1,450 views