我尝试使用laravel excel创建下拉列表但是下载下拉列表似乎没有出现,甚至不会抛出错误。
$ 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');
});
答案 0 :(得分:0)
我发现在使用Maatwebsite的Laravel Excel时,addNamedRange
无法按预期工作。
你必须改变:
$objValidation->setFormula1('classdata');
要:
$objValidation->setFormula1('ProductList!$A$2:$A$7');
ProductList 是您的工作表名称, A2:A7 是单元格