php - Laravel excel library(Maatwebsite) : How to create a drop down list in exports -
i creating excel template should contain dropdown list. see possible phpexcel library (phpexcel multiple dropdown list dependent). wondering if done laravel-excel library provided maatwebsite. need syntax functions dropdown,namedrange, datavalidation,setformula, etc.
public function index() { \excel::create('file', function($excel) { require_once("/apppath//vendor/phpoffice/phpexcel/classes/phpexcel/namedrange.php"); require_once("/apppath/vendor/phpoffice/phpexcel/classes/phpexcel/cell/datavalidation.php"); $excel->sheet('new sheet', function($sheet) { $sheet->setcellvalue("a1", "uk"); $sheet->setcellvalue("a2", "usa"); $sheet->_parent->addnamedrange( new \phpexcel_namedrange( 'countries', $sheet, 'a1:a2' ) ); $sheet->setcellvalue("b1", "london"); $sheet->setcellvalue("b2", "birmingham"); $sheet->setcellvalue("b3", "leeds"); $sheet->_parent->addnamedrange( new \phpexcel_namedrange( 'uk', $sheet, 'b1:b3' ) ); $sheet->setcellvalue("c1", "atlanta"); $sheet->setcellvalue("c2", "new york"); $sheet->setcellvalue("c3", "los angeles"); $sheet->_parent->addnamedrange( new \phpexcel_namedrange( 'usa', $sheet, 'c1:c3' ) ); $objvalidation = $sheet->getcell('d1')->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 not in list.'); $objvalidation->setprompttitle('pick list'); $objvalidation->setprompt('please pick value drop-down list.'); $objvalidation->setformula1('countries'); //note this! }); })->download("xlsx"); return view('home'); }