1、安装
composer require maatwebsite/excel 之后,程序中就可以使用 PHPExcel 了
2、控制器中
public function export(Request $request)
{
$Excel = new PHPExcel();
$Excel->setActiveSheetIndex(0);
$sheet = $Excel->getActiveSheet();
$sheet->setTitle('数据');
$sheet->setCellValue('A1', '我是你爸爸');
$sheet->setCellValue('A2', '好啊好呃');
header('Content-Type:application/download');
header('Content-Disposition:attachment;filename="foo.xls"');
$Writer = new PHPExcel_Writer_Excel5($Excel);
$Writer->save('php://output');
}