0

I tried creating drop down list using laravel excel but after download dropdown list seems not to appear and doesnt even throw errors.

Here is the code below:

$excelsheet->sheet('ClassBoardData', function($sheet1) use($cc, $highrowofclass, $highrowofboard) { $variantsSheet = $sheet1->_parent->getSheet(1); $range = 'B1:B' . $highrowofclass;

              $sheet1->_parent->addNamedRange(new \PHPExcel_NamedRange('classdata', $variantsSheet, $range));


            $objValidation = $sheet1->getCell('A1')->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 the list.');
            $objValidation->setPromptTitle('Pick from the list');
            $objValidation->setPrompt('Please pick a value from the drop-down list.');
            $objValidation->setFormula1('classdata');
        });
Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

I've found that when using Maatwebsite's Laravel Excel, addNamedRange doesnt work as expected.

You have to change:

$objValidation->setFormula1('classdata');

To:

$objValidation->setFormula1('ProductList!$A$2:$A$7');

Where ProductList is your sheet name and A2:A7 are the cells