PHPExcel how to generate excel file via controller of Laravel 5 -
i use library phpexcel included in classes
directory. simple test in controller. in controller, placed code:
`include(app_path().'/classes/phpexcel.php');` `include(app_path().'/classes/phpexcel/writer/excel2007.php');`
then instantiate object phpexcel :
`$workbook = new phpexcel;`
i activate sheet on work (the default form), method ->getactivesheet()
.
`$sheet = $workbook->getactivesheet();`
i filled first cell method ->setcellvalue()
.
`$sheet->setcellvalue('a1','maitrepylos');`
finally create file, need instantiate object writer, specific type of picture want generate.
`$writer = new phpexcel_writer_excel2007($workbook);`
i give name file, , save :
`$records = 'storage/app/sampledata/fichier.xlsx';` `$writer->save($records);`
result: have generated error class 'app\http\controllers\phpexcel_writer_excel2007' not found
who can me better organize code , fix error problem?
just use laravel excel package, behind scenes uses phpexcel class.
Comments
Post a Comment