PHPExcel setFormula1 ( If a lot does not work)

Mar 15, 2012 at 7:44 AM

$ary=array('CASUAL','ROCK','ffff',...);  //If a lot does not work
selectItems=join(',',$ary);
$objPHPExcel = new PHPExcel();
$activeSheet = $objPHPExcel->getActiveSheet();

$objValidation = $activeSheet->getCell("A1")->getDataValidation();
$objValidation->setType( PHPExcel_Cell_DataValidation::TYPE_LIST )
->setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_INFORMATION )
->setAllowBlank(false)
->setShowInputMessage(true)
->setShowErrorMessage(true)
->setShowDropDown(true)
->setErrorTitle('')
->setError('')
->setPromptTitle('')
->setPrompt('')
->setFormula1('"'. $selectItems .'"'); 

$activeSheet->setTitle('sheet1');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('demo.xls');

 

 

 

 

 

 

 

 

Aug 17, 2012 at 11:29 AM

Hello

I think you have some code like this

$objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, 'Excel2005');

if you change Excel2005 to Excel2007

Aug 17, 2012 at 11:30 AM

And at excel2007, if you make a dropdownlist, the data max length is 265