ImpendingDoom ImpendingDoom - 1 year ago 219
PHP Question

How to increase cell character limit PHPExcel TYPE LIST

Using PHPExcel to create a dropdown list like so:

$objValidation = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getDataValidation();
$objValidation->setType( \PHPExcel_Cell_DataValidation::TYPE_LIST );
$objValidation->setErrorStyle( \PHPExcel_Cell_DataValidation::STYLE_INFORMATION );
$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.');
$formulaString = '"' . implode(", ", $items_array) . '"';

$objWriter = new \PHPExcel_Writer_Excel2007($objPHPExcel);
$filename = "MyExcel.xlsx";
header('Content-Type: application/');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');

The problem is it cuts off at
characters hence breaking the "dropdown" function.

How do I increase the character limit?

Answer Source

As discussed in the comments, there is a limit to the length of a static list in data validation.

You should put the validation data in a range in the workbook somewhere and provide this range for the validation:

// Get options from another sheet
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download